将脚本文件添加到您的项目文件夹:
SCHEME=TestFramework \
ARCHS=~/Documents/Archives \
SCHEME
是 Xcode 中构建方案的名称。
让我们构建 macCatalyst 存档:
#----- Make macCatalyst archive
xcodebuild archive \
-scheme $SCHEME \
-archivePath $ARCHS/macCatalyst.xcarchive \
-sdk macosx \
SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES SUPPORTS_MACCATALYST=YES
您还可以添加其他平台,如 iOS 设备或模拟器:
#----- 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
要在 XCFramework 中包含所有内容,请使用:
#----- 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
运行后,您将在 Documents 文件夹中找到您的 XCFramework。