WWDC Notes

Binary Frameworks in Swift

Show Apple's description.
Xcode 11 now fully supports using and creating binary frameworks in Swift. Find out how to simultaneously support devices and Simulator with the new XCFramework bundle type, how Swift module interfaces work, and how to manage changes to your framework over time.

XCFramework

  • A XCFramework is multiple binary frameworks in one package.
  • You can bundle:
    • a variant of the framework for each target (iPhones, Simulators).
    • a variant of the same framework for different platforms:
  • We can also have variants with different dependencies as well:
  • XCFrameworks support both Swift and “c-based” code.

How do XCFrameworks work?

Like another binary, but the header is a new Swift Module Interfaces type, which, kind of like the Package.swift file for SPM packages, contains information on the required compiler version and a full list of public classes and methods available from within the framework.

How to create a XCFrameworks

  • We have a new setting:
  • In order to release a binary we need to archive the framework (a.k.a. build in release mode) and the output will be available in the organizer.
  • The default path is:

 - We can change the output path in Xcode Locations from the preferences window.

  • After archiving different frameworks we can create a final .xcframework by using the command line:

Missing anything? Corrections? Contributions are welcome 😃

Related

Written by

zntfdr

Federico Zanetello

Federico Zanetello is an iOS Engineer with strong passion for Swift, minimalism, and design. When he’s not busy automating things, he can be found writing at fivestars.blog and/or playing with the latest shiny toys.