Skip to content
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

Fat multiplatform framework #13

Closed
sebarthel89 opened this issue Nov 30, 2020 · 3 comments
Closed

Fat multiplatform framework #13

sebarthel89 opened this issue Nov 30, 2020 · 3 comments

Comments

@sebarthel89
Copy link

Hey,

I have another issue bundling a fat framework.

I added a task called universalFrameworkRelease that bunldes simulator and native ios builds. Is it possible to support as well?

Not sure, but maybe it's optional to add a bunch of additional paths that are used for more sift packages.

additionalFrameworkPaths {
   path = "build/bin/universal/release"
   name = "universal"
}

Here is an example: https://github.com/sebarthel89/example-kmp-swift-package

@ge-org
Copy link
Owner

ge-org commented Nov 30, 2020

Hey @sebarthel89,

thanks for the feedback. I'm not sure if I understand your use case correctly.
The whole purpose of an XCFramework is to get rid of fat frameworks. The XCFramework already contains the framework for all architectures. Xcode will then pick the right one when it builds the project.

The sample project declares iosArm64 and iosX64. The plugin is configured with iOS { v("13") }. So the resulting XCFramework will contain the ARM build and the simulator build.

When you take a look at the contents of the generated XCFramework you can actually see that both architectures are present.

./gradlew createXCFramework
cd swiftpackage
ls MyFramework.xcframework

Will print

Info.plist
ios-arm64
ios-x86_64-simulator

@sebarthel89
Copy link
Author

sebarthel89 commented Dec 1, 2020

That's a good question. I am not mobile developer and still learning a lot in this direction. So the swift-package format solves it by itself, right?

I had only a look at the binaries, one is build with multiple targets and one with only a single target:

Some KMP library that is build for multiple architectures (simulator + native ios)

lipo -info SomeLibrary
Architectures in the fat file: SomeLibrary are: i386 x86_64 armv7 arm64

Some other library that is only build for a single target

lipo -info SomeOtherLibrary
Non-fat file: SomeOtherLibrary is architecture: arm64

We can close this issue for now and I will verify how smart XCode is picking the right architecture for an imported swift package.

@ge-org
Copy link
Owner

ge-org commented Dec 1, 2020

The lipo tool basically merges two architectures into one. The downside is that Apple will not accept such a framework when you submit the app to the App Store. So before shipping it you have to remove the simulator stuff again.

By using an XCFramework you can omit this step because Xcode will always select the correct architecture depending on your build type.

To use the XCFramework you can drag&drop it into Xcode.

Let me know if you need more info or support.

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

No branches or pull requests

2 participants