Skip to content

Instantly share code, notes, and snippets.

@priore
Created April 10, 2024 13:56
Show Gist options
  • Save priore/e8876760425fe85f73a098ec7d512594 to your computer and use it in GitHub Desktop.
Save priore/e8876760425fe85f73a098ec7d512594 to your computer and use it in GitHub Desktop.
Script to create multiple Archs XCFramework from your native library code
#!/bin/sh
#
# BUILD PLATFORM SPECIFIC FRAMEWORKS
#
# rember before use: chmod +x create_xcframework.sh
# iOS devices
xcodebuild archive \
-scheme "MyLibrary iOS" \
-archivePath "./build/ios.xcarchive" \
-sdk iphoneos \
-configuration Release \
SKIP_INSTAL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
# iOS simulator
xcodebuild archive \
-scheme "MyLibrary iOS" \
-archivePath "./build/ios_sim.xcarchive" \
-sdk iphonesimulator \
-configuration Release \
SKIP_INSTAL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
# OSX
xcodebuild archive \
-scheme "MyLibrary OSX" \
-archivePath "./build/osx.xcarchive" \
-configuration Release \
-sdk macosx \
SKIP_INSTAL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES \
SUPPORTS_MACCATALYST=YES
#
# PACKAGE XCFRAMEWORK
#
xcodebuild -create-xcframework \
-framework "./build/ios.xcarchive/Products/Library/Frameworks/MyLibrary.framework" \
-framework "./build/ios_sim.xcarchive/Products/Library/Frameworks/MyLibrary.framework" \
-framework "./build/osx.xcarchive/Products/Library/Frameworks/MyLibrary.framework" \
-output "./build/MyLibrary.xcframework"
#rm "./build/ios.xcarchive"
#rm "./build/ios_sim.xcarchive"
#rm "./build/osx.xcarchive"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment