Skip to content

Conversation

@freakboy3742
Copy link
Contributor

@freakboy3742 freakboy3742 commented Nov 18, 2025

Adds a lib folder to each slice of an iOS XCframework that contains a libpython*.dylib symlink to the underlying Framework dylib.

This mirrors the structure of macOS frameworks, allowing iOS binary modules to be compiled with -L path/to/python/lib -lpython, rather than requiring -F path/to/Framework -framework Python. This increases compatibility with standard Unix tooling for building binary modules.

The libpython*.dylib must be explicitly excluded from being copied into the architecture-specific library folders, so that the dylib (or a symlink) won't be copied into the app binary.

The final structure of a full XCframework will look something like:

  • Python.xcframework
    • lib
      • cross-platform copy of the standard libray
    • ios-arm64
      • include
      • lib
        • libpython.dylib - link to ../Python.framework/Python
      • lib-arm64
        • arm64 device-specific standard library parts (sysconfig, build-details.json etc)
      • Python.framework
    • ios-arm64_x86_64-simulator
      • include
      • lib
        • libpython.dylib - link to ../Python.framework/Python
      • lib-arm64
        • arm64 simulator-specific standard library parts (sysconfig, build-details.json etc)
      • lib-x86_64
        • x86_64 simulator-specific standard library parts (sysconfig, build-details.json etc)
      • Python.framework

Copy link
Member

@ned-deily ned-deily left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks to me like a good idea.

@freakboy3742 freakboy3742 merged commit 7b0b708 into python:main Nov 19, 2025
46 checks passed
@freakboy3742 freakboy3742 deleted the ios-linkable-dylib branch November 19, 2025 01:48
@miss-islington-app
Copy link

Thanks @freakboy3742 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 19, 2025
…pythonGH-141693)

Modifies the iOS XCframework to include a lib folder for each slice that
contains a symlinked version of the libPython dynamic library.
(cherry picked from commit 7b0b708)

Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
@bedevere-app
Copy link

bedevere-app bot commented Nov 19, 2025

GH-141733 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Nov 19, 2025
freakboy3742 added a commit that referenced this pull request Nov 19, 2025
GH-141693) (#141733)

Modifies the iOS XCframework to include a lib folder for each slice that
contains a symlinked version of the libPython dynamic library.
(cherry picked from commit 7b0b708)

Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants