Add script file to your projects folder:
SCHEME=TestFramework \
ARCHS=~/Documents/Archives \
SCHEME
is the name of build scheme in Xcode.
Lets build macCatalyst archive:
#----- Make macCatalyst archive
xcodebuild archive \
-scheme $SCHEME \
-archivePath $ARCHS/macCatalyst.xcarchive \
-sdk macosx \
SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES SUPPORTS_MACCATALYST=YES
Also you can add other platforms like iOS device or Simulator:
#----- Make iOS Simulator archive
xcodebuild archive \
-scheme $SCHEME \
-archivePath $ARCHS/simulator.xcarchive \
-sdk iphonesimulator \
SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
#----- Make iOS device archive
xcodebuild archive \
-scheme $SCHEME \
-archivePath $ARCHS/iosdevice.xcarchive \
-sdk iphoneos \
SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
To include everything in XCFramework use:
#----- Make XCFramework
xcodebuild -create-xcframework \
-framework $ARCHS/simulator.xcarchive/Products/Library/Frameworks/$SCHEME.framework \
-framework $ARCHS/iosdevice.xcarchive/Products/Library/Frameworks/$SCHEME.framework \
-framework $ARCHS/macCatalyst.xcarchive/Products/Library/Frameworks/$SCHEME.framework \
-output ~/Documents/$SCHEME.xcframework
After running you will find your XCFramework in your Documents folder.