-
-
Notifications
You must be signed in to change notification settings - Fork 589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abstract apple framework creation behind a tool. #1679
base: master
Are you sure you want to change the base?
Conversation
39ab389
to
7986baa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- iOS portion is wrong.
- It's not using lipo on macOS.
- It's not necessary for macOS, only iOS is restricted to not use dylibs.
iOS xcframework
should have structure like this:
ios-arm64 # folder with either .framework or static lib (.a) inside
ios-arm64_x86_64-simulator # folder with either .framework or static lib (.a) inside
Info.plist # list of target platforms
Info.plist
is like:
<?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>AvailableLibraries</key>
<array>
<dict>
<key>BinaryPath</key>
<string>__name__.framework/__name__</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>__name__.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>__name__.framework/__name__</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>__name__.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
</dict>
</array>
<key>CFBundlePackageType</key>
<string>XFWK</string>
<key>XCFrameworkFormatVersion</key>
<string>1.0</string>
</dict>
</plist>
I would suggest doing framework generation as an extra step to allow combining all required versions with lipo
and xcframework (see how generate_bundle
is used in the Godot build).
test/SConstruct
Outdated
env["platform"], env["target"], env["platform"], env["target"] | ||
), | ||
if env["platform"] == "macos" or env["platform"] == "ios": | ||
# Static libraries (.dylib) are not supported on the iOS app store. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Static libraries (.dylib) are not supported on the iOS app store. | |
# Dynamic libraries (.dylib) are not supported on the iOS app store. |
Static libraries (.a) are supported on iOS, as well as dynamic .frameworks
and .xcframeworks
with both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be good to document somewhere better than a single comment.
test/SConstruct
Outdated
if env["ios_simulator"]: | ||
framework_name += ".simulator" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? The only purpose of .xcframework
is to contain libs for multiple targets, so there should not be separate simulator xcframework.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, the previous code confused me too, but I merely adapted what I found.
test/SConstruct
Outdated
framework_name += ".simulator" | ||
|
||
library_targets = framework_tool.generate( | ||
f"project/bin/{framework_name}.xcframework", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be .framework
for macOS, and .xcframework
for iOS (it's a different format with different plist).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could be wrong, but a superficial search told me .framework
is for single-platform libraries while .xcframework
is for multi-platform libraries. Perhaps we can get away with .framework
on both?
Edit: I suppose .xcframework
was perhaps preferred to indulge the .simulator
builds being part of the same framework?
It was definitely too late when I was working on this 😅
This is indeed a problem I'd like to see addressed too.
That's true; there is a comment in the code that addresses this. Anyway it's not a change of behavior, building frameworks is what the demo does right now anyway (and other users can always decide to just not call the framework creation tool for macOS).
Right, I have totally misunderstood
I think that's a good idea! I'm happy to indulge once we have some sort of plan for integrating |
Yes, but with normal |
1e9bd08
to
d9693ec
Compare
I have refactored the PR to be a lot more versatile.
The way test/SConscript is set up now actually generates both a In either case, I'm a lot more happy with the structure now, and i'd be happy to receive some more feedback! |
c0f8efc
to
7137666
Compare
…e input binaries together and create an appropriate `Info.plist`.
7137666
to
3bfe5fd
Compare
The limitation on dynamic libraries on iOS was removed some time ago, it is now possible to use dynamic libraries in iOS. |
The new tool will take library binaries, and merge them with
lipo
to create a valid.framework
bundle.The main reason to do this is to simplify
.framework
/.xcframework
creation for godot-cpp users.This may help alleviate adoption problems when releasing framework bundles for macOS. I personally have found this to be a bit confusing at first.
Also, currently, copies of
Info.plist
have to be copied around needlessly across build combinations, as each framework needs their own in appropriate spots. This PR removes this boilerplate by generating appropriateInfo.plist
.Edit: Whoops, wrong branch. But no matter, the other PR had already been merged.