If you create new project from Xcode (v16) and choose framework, and then build it, it results in a .framework.
How do you instead get it to build an .xcframework?
When creating the framework project there’s no options presented to create one or the other.
Question posted in Xcode
Whether you're new to Xcode or an experienced developer, our archive has everything you need to know about this integrated development environment (IDE). From basic functionalities to advanced features, our archive covers a wide range of Xcode-related questions and answers. Browse our archive now and find solutions to your Xcode questions, and take your app development skills to the next level
Whether you're new to Xcode or an experienced developer, our archive has everything you need to know about this integrated development environment (IDE). From basic functionalities to advanced features, our archive covers a wide range of Xcode-related questions and answers. Browse our archive now and find solutions to your Xcode questions, and take your app development skills to the next level
2
Answers
An xcframework is an archive of frameworks with different architectures. You should create the framework first and then create the xcframework. An xcframework is somewhat like a fat framework.
First, create frameworks for each architecture. Then, create the xcframework by:
To create an
.xcframework
instead of a.framework
in Xcode, follow these steps:”Create a New Xcode Project or Use Existing Framework Project”
Open Xcode and either create a new project or use an existing project containing the
.framework
you want to convert to an.xcframework
.”Build the Framework for Different Architectures/Platforms”
.xcframework
allows you to package multiple frameworks for different platforms (e.g., iOS, macOS, etc.) and architectures (e.g., arm64, x86_64). You need to build the framework for these different combinations.In your Xcode project, set the build target to include the platforms and architectures you want the
.xcframework
to support.”Archive the Framework for Each Platform and Architecture”
For each platform you want to support (e.g., iOS, macOS, etc.), follow these steps:
You need to archive your framework for every target architecture (e.g.,
arm64
,x86_64
) and platform (e.g., iOS, macOS).”Create the
.xcframework
”Once you have all the archives for the different platforms/architectures, you can create an
.xcframework
by following these steps:This will create the
.xcframework
that includes the frameworks for all the platforms and architectures you’ve built.Verify the .xcframework
Once the
.xcframework
is created, verify that it contains the correct framework for each target platform and architecture. You can inspect it using the terminal:This will show the architectures included in the framework.
Distribute the
.xcframework
After successfully creating the
.xcframework
, you can distribute it by sharing the.xcframework
file. This can be added to projects via CocoaPods, Carthage, or directly integrated into your own project.Alternative: Using the Command Line
If you prefer using the command line, you can use
xcodebuild
to build the framework and then usexcodebuild createxcframework
to package it as an.xcframework
: