XCFramework is a new code distribution format introduced by Apple in Xcode 11. The new XCFramework bundle type (similar to framework bundle) now allows to support multiple architectures, platforms and simulator in one package. As XCFrameworks are gaining in popularity, iOS developers will need to know how to use them in their projects. This tutorial covers the steps needed to add and integrate an existing XCFramework into your Xcode project.
First of all, double check if your Xcode project contains a “Frameworks” folder in project navigator. If it doesn’t, just like in the screenshot below, then we’ll have to create one. The Frameworks folder is not added by default in latest Xcode and it’s a good practice to keep your frameworks there.
Create Frameworks folder
Right click on your project in the project navigator (top-most entry) , and select “New Group”. Name the new group Frameworks.
Add XCFramework to Frameworks folder
There are two ways to add an XCFramework to the Frameworks folder.
Drag and drop it from Finder into the Frameworks folder. Make sure that the destination of drag is just under the Frameworks folder:
Then, make sure the following options are selected for adding files. Both “Copy items if needed” and “Create groups” should be checked and selected. Click Finish.
The result should look like this:
Alternatively, with the Frameworks folder selected, click on File -> Add Files to “Your Project”…
Find the XCFramework in the file navigator, select it, make sure “Copy items if needed” and “Create groups” are selected and click Add:
Embed XCFramework in project’s target
In order to make sure that the framework will get copied to your app’s binary, follow these steps:
- Navigate to your project settings by clicking on it in the project navigator.
- Make sure that your target is selected and General tab is open.
- Select “Embed & Sign” for your newly added XCFramework
Link XCFramework with your project
Navigate to the Build Phases tab, disclose the “Link Binary With Libraries” list and make sure your framework is included in the list. It should already be included by default after following the steps above, however in case it’s not – click on the + button and add it.
The XCFramework is now fully added and integrated with your Xcode project.
Take a look at Apple’s video from WWDC introducing XCFrameworks.
- How to add missing iPhone SE simulator in Xcode 11 with iOS 13 SDKs
- How to add image to Xcode project in SwiftUI
- How to create a single view iOS app in Xcode