How do I build an XCFramework for distribution?

Creating an XCFramework for distribution allows developers to package and share their libraries across multiple platforms (iOS, macOS, tvOS, etc.) efficiently. This guide outlines the process to build an XCFramework from your existing Swift framework.

Step-by-Step Guide to Build an XCFramework

  1. Open your terminal and navigate to your project's root directory.
  2. Use the following command to build the framework for individual platforms:
  3. xcodebuild -create-xcframework \ -framework path/to/YourFramework-iOS.xcframework \ -framework path/to/YourFramework-macos.xcframework \ -output path/to/YourFramework.xcframework
  4. This command consolidates the separate frameworks into a single XCFramework.
  5. After execution, check the specified output path for your new XCFramework.

Distributing Your XCFramework

You can now share the generated XCFramework file with other developers or upload it to a package manager like CocoaPods or Swift Package Manager for easy integration.


XCFramework Swift framework iOS development macOS framework XCFramework distribution Build XCFramework Framework packaging