IOS – creating a framework

以下資料皆來自Ref,這裏僅作個人筆記整理

Ref: https://www.raywenderlich.com/17753301-creating-a-framework-for-ios

pack ios archive of framework

xcodebuild archive \
-scheme TestFramework \
-configuration Release \
-destination ‘generic/platform=iOS’ \
-archivePath ‘./build/TestFramework.framework-iphoneos.xcarchive’ \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES

pack ios simulator archive of framework

xcodebuild archive \
-scheme TestFramework \
-configuration Release \
-destination ‘generic/platform=iOS Simulator’ \
-archivePath ‘./build/TestFramework.framework-iphonesimulator.xcarchive’ \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES

pack macOS Catalyst archive of framework

xcodebuild archive \
-scheme TestFramework \
-configuration Release \
-destination ‘platform=macOS,arch=x86_64,variant=Mac Catalyst’ \
-archivePath ‘./build/TestFramework.framework-catalyst.xcarchive’ \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES

Generating the XCFramework

xcodebuild -create-xcframework \
-framework ‘./build/TestFramework.framework-iphonesimulator.xcarchive/Products/Library/Frameworks/TestFramework.framework’ \
-framework ‘./build/TestFramework.framework-iphoneos.xcarchive/Products/Library/Frameworks/TestFramework.framework’ \
-output ‘./build/TestFramework.xcframework’