No more ‘Lipo’ for create universal framework

iOS, iOS Simulator, macOS binaries together, Using XCFramework

MdNiks
3 min readMay 25, 2020

Welcome Guys,

Always Apple comes up with new things, Everybody knows apple was introduced ABI Stability (or Module stability) Swift 5.1 onwards. For more details of ABI Stability, please review apple document link: https://swift.org/blog/abi-stability-and-more/

We are following traditional methodology for creating a universal framework using Lipo command, but this approach has some drawback like if you have created a framework using Xcode 11.3 and swift 5.1. It’s not supported in Xcode 11.4.1, why because swift version changed so once again you need to execute framework creation process and distribute. Right?

XCFramework is born to replace the traditional universal framework format .framework, which can contain both simulator and physical device architectures code. Besides, XCFramework can also support Catalyst, Mac, watchOS inside a framework

Heading to build binaries for distribution

For a start at all target projects, which are responsible for compiling the lib under target platforms, it is needed to enable new for Xcode 11 setting — «Build Libraries for Distribution».

Creating XCFramework aggregate target

Create a new target of type Aggregate (Cross-platform category) — naming it something like “BiometricAuthentication.xcframework”:

Under its Build Phases add a Run Script section there, to be able to generate the .xcframework output — at this time it requires command lines:

Also, I inserted a rm -rd command at the beginning of the script to ensure the output .xcframework folder is cleaned up when rebuilding.

echo “Welcome MdNiks”
FRAMEWORK_NAME=”BiometricAuthentication”

rm -rd “${FRAMEWORK_NAME}.xcframework”

xcodebuild -create-xcframework \
-framework “${BUILD_DIR}/${CONFIGURATION}-iphoneos/${FRAMEWORK_NAME}/${FRAMEWORK_NAME}.framework” \
-framework “${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}/${FRAMEWORK_NAME}.framework” \-output “BiometricAuthentication.xcframework”

Here I have manually build “BiometricAuthentication” target one by one (simulator and generic iOS Device). then you have found both folder in build folder location.

Now time to Build “BiometricAuthentication” Aggregate target

And then build succeeded, Just review your project folder you can find out .xcframework

Distributing the package

Compress “BiometricAuthentication.xcframework” into a zip file and — boom — you’re ready: you may now distribute it freely to third parties.

(Before distributing first verify yourself and make sure all things are good your hand).

Just use it. w00t! How cool is that and all done with just follow fews steps.

If you have any comments or questions, please respond below! I’d love to hear from you.

--

--

MdNiks

I'm an accomplished iOS programmer with more than 12 years of experience working in a collaborative environment with tight deadlines.