- Support for multiple platforms in the same framework.
- Support for Swift, Objective-C and C.
- Support for dynamic frameworks and static libraries.
- Support for Swift Package Manager.
- End of fat binaries.
- Open Current framework project
- File -> New -> Target
- Choose 'Other' tab -> Aggregate
- I just named that target as 'MyFramworkUniversal'
- Goto Build Phases -> Tap + Button -> New Run Script Phase. Then Add the code below.
#Gerenare device framework
xcodebuild archive -scheme ${PROJECT_NAME} -archivePath "${PROJECT_DIR}/build/${PROJECT_NAME}-iphoneos.xcarchive" -sdk iphoneos SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
#Generate simulator framework
xcodebuild archive -scheme ${PROJECT_NAME} -archivePath "${PROJECT_DIR}/build/${PROJECT_NAME}-iossimulator.xcarchive" -sdk iphonesimulator SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
#Generate xcframework for both arches
xcodebuild -create-xcframework -framework "${PROJECT_DIR}/build/${PROJECT_NAME}-iphoneos.xcarchive/Products/Library/Frameworks/${PROJECT_NAME}.framework" -framework "${PROJECT_DIR}/build/${PROJECT_NAME}-iossimulator.xcarchive/Products/Library/Frameworks/${PROJECT_NAME}.framework" -output "${PROJECT_DIR}/build/${PROJECT_NAME}.xcframework"
#Open directory where xcframework were generate
open "${PROJECT_DIR}/build"
- Set Build Libraries for Distribution to Yes in Build settings.
- Set Skip Install to No in Build settings. Above steps are just to make confirm that the above flags are set.
- Select 'MyFramworkUniversal' scheme & run target as 'Any iOS Device'
- Build and Run
- Script will automatically open the directory where the xcframework were generated.
https://www.appcoda.com/xcframework/ https://andresalla.dev/en/2020/06/02/the-end-of-fat-binaries-xcframeworks/