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

[Apple platforms] Add support to create .xcframework #15055

Closed
bielikb opened this issue Jul 20, 2019 · 3 comments
Closed

[Apple platforms] Add support to create .xcframework #15055

bielikb opened this issue Jul 20, 2019 · 3 comments

Comments

@bielikb
Copy link

bielikb commented Jul 20, 2019

Feature Request

Add a fastlane action to create an .xcframework from the given list of destinations.

Motivation Behind Feature

1. Module Stabilty (available since Swift 5.1)
Without the Module Stability the authors of Swift frameworks are required to rebuild & distribute frameworks for every new Swift version.

Since XCode 11, the framework authors are given an option to build their binaries with Module Stability known as .xcframework.

.xcframework is an Xcode recognised format, that contains binaries for selected Apple platforms and architectures. Xcode will automatically pick the right binary for given architecture (e.g. binary built for simulators will be picked, when building against simulator).

To learn more about the .xcframeworks:
Binary Frameworks in Swift (WWDC '19)

Sample project that excercises the creation & use of xcframeworks

2. Standardized way to integrate closed source binaries in Xcode.

XCFrameworks are the replacement of well adopted concept of fat frameworks that lacks the standardisation and ease of integration within the Xcode.

The problem statement:

Fat framework requires:

  • the author to create fat framework by combining the binaries built for simulator & device architectures
  • the integrator to add additional build phase step within the project's target to strip the unneeded architecture (e.g. simulator architecture). Skipping the strip build phase would lead to Appstore rejection.

This tedious handling on both author & integrator side can be resolved by using the .xcframework:

  • the author will create xcframework for platforms & architectures of interest.
  • the integrator will drag & drop the .xcframework to his Xcode project. The Xcode will pick the binary with given architecture automatically => no additional build phase needed

Feature Description

Add create_xcframework action to fastlane (similar to build_app)

create_xcframework action would:

1. Archive the given scheme for given list of destinations

  • In order to correctly archive the framework scheme, pass SKIP_INSTALL=NO & BUILD_LIBRARY_FOR_DISTRIBUTION=YES

Example:

 xcodebuild archive -workspace "XCFrameworks.xcworkspace" 
                                  -scheme "DynamicFramework" 
                                  -destination "generic/platform=iOS Simulator" 
                                  -archivePath "path_to_simulator_archive"  
                                  SKIP_INSTALL=NO 
                                  BUILD_LIBRARY_FOR_DISTRIBUTION=YES | xcpretty
 xcodebuild archive -workspace "XCFrameworks.xcworkspace" 
                                  -scheme "DynamicFramework" 
                                  -destination "generic/platform=iOS" 
                                  -archivePath "path_to_device_archive"  
                                  SKIP_INSTALL=NO 
                                  BUILD_LIBRARY_FOR_DISTRIBUTION=YES | xcpretty

where binaries in .xcarchive can be located under:

  • Products/Library/Frameworks folder for dynamic frameworks
  • Products/usr/local/lib folder for static libraries

2. Create xcframework from list of archived binaries

Example:

xcodebuild -create-xcframework 
                   -framework "path_to_archived_simulator_binary".framework 
                  -framework "path_to_archived_device_binary".framework  
                 -output "xcframework_path.xcframework"

where xcframework_path is the output path

3. Include dSYMs
dSYMs are available in .xcarchives

4. Include BCSymbolMaps
BCSymbolMaps are available in .xcarchives


Sample project that demostrates 1st & 2nd step can be found in this repo

Alternatives or Workarounds

Continue using fat frameworks, that wont offer Module Stability

This is breaking change for users of fat frameworks. When dealing with .xcframeworks, they should

  • remove fat framework from their Xcode project
  • remove build phase step that strips the architectures for fat framework
@bielikb
Copy link
Author

bielikb commented Jul 22, 2019

Ill gladly help with the implementation, though I'd like to get some feedback to the provided feature request - e.g. how to properly scope the API of such a toolchain action so it would follow the best practices in fastlane. After that prototyping phase, the implementation is actually pretty straightforward

@fastlane-bot
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest fastlane version and check if that solves the issue. Let us know if that works for you by adding a comment 👍

Friendly reminder: contributions are always welcome! Check out CONTRIBUTING.md for more information on how to help with fastlane and feel free to tackle this issue yourself 💪

@fastlane-bot
Copy link

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants