-
Notifications
You must be signed in to change notification settings - Fork 457
Notes: packaging for iOS
Feodor Fitsner edited this page May 8, 2024
·
10 revisions
- Use
lipo
command to create a framework library from.dylib
for every architecture:ios-arm64
ios-arm64-simulator
ios-x86_64-simulator
- Change frameworks library names with
install_name_tool
. - Create
Info.plist
for every framework library in<arch>/<package>.framework
directory:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>{python-package-name}</string>
<key>CFBundleIdentifier</key>
<string>com.{company_name}.{python-package-name}</string>
<key>CFBundleVersion</key>
<string>{python-package-version}</string>
<key>CFBundleShortVersionString</key>
<string>{python-package-version}</string>
<key>CFBundleExecutable</key>
<string>{python-package-name}</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>iPhoneOS</string>
</array>
<key>MinimumOSVersion</key>
<string>12.0</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
</dict>
</plist>
- Merge multiple
.framework
into.xcframework
withxcodebuild -create-xcframework
. - Remove
rpath
s of references frameworks fromserious_python_darwin
.
Sources:
- https://stackoverflow.com/questions/48701584/how-to-properly-embed-3rd-party-dylib-files-in-ios-app-project-for-app-store-re
- https://stackoverflow.com/questions/53818772/embedding-a-dylib-inside-a-framework-for-ios/62962630#62962630
- https://stackoverflow.com/questions/2985315/using-install-name-tool-whats-going-wrong
- https://medium.com/@donblas/fun-with-rpath-otool-and-install-name-tool-e3e41ae86172
- https://medium.com/walmartglobaltech/ios-library-bundle-and-frameworks-8fdc0aac6952
- https://developer.apple.com/library/archive/technotes/tn2435/_index.html
- https://github.com/beeware/Python-Apple-support/blob/main/patch/Python/Python.patch#L89
- https://itwenty.me/posts/01-understanding-rpath/
- https://github.com/PyO3/maturin/issues/1742#issuecomment-2099461241
Check what architectures are embedded into a library/executable - file:
file <library.dylib>
Check library/executable references - otool:
otool -L <path-to-exec-or-library>
Merging static/dynamic libraries into a library or framework - lipo:
lipo -create <library1.dylib> <library2.dylib> ... -output <library>
Create .xcframework
from multiple .framework
s:
xcodebuild -create-xcframework \
-framework ios-arm64/a.framework \
-framework ios-arm64-simulator/a.framework \
-output a.xcframework
Change library references - install_name_tool:
install_name_tool -change <old-reference> <new-reference> <library>
Change library name:
install_name_tool -id @rpath/<name>.framework/<name> <name>
Check library exported functions - nm:
nm -gU <library>