已有framework(源码)构建xcframework

1.启用Build Libraries for Distribution

Xcode打开当前Framework工程,选中Target->Build Settings->Build Libraries for Distribution,将其值设置为YES

2.生成xcarchive

打开终端,cd到Framework源码所在目录,以~/Desktop/MyFramework为例。
cd ~/Desktop/MyFramework

创建模拟器运行的framework:
xcodebuild archive -scheme MyFramework -archivePath ~/Desktop/MyFramework-iphonesimulator.xcarchive -sdk iphonesimulator SKIP_INSTALL=NO

创建真机运行的framework:
xcodebuild archive -scheme MyFramework -archivePath ~/Desktop/MyFramework-iphoneos.xcarchive -sdk iphoneos SKIP_INSTALL=NO

将两个xcarchive中的framework合并为xcframework:
xcodebuild -create-xcframework -framework ~/Desktop/MyFramework-iphonesimulator.xcarchive/Products/Library/Frameworks/MyFramework.framework -framework ~/Desktop/MyFramework-iphoneos.xcarchive/Products/Library/Frameworks/MyFramework.framework -output ~/Desktop/MyFramework.xcframework

去桌面查看,一切顺利的话,应该可以看到MyFramework.xcframework了。支持iPhone/iPad模拟器和真机使用。

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×