把framework 转 为xcframework

1. 先分别看下两个的结构

0x01 framework

把framework 转 为xcframework_第1张图片
framework

0x02 xcframework

把framework 转 为xcframework_第2张图片
xcframework

2. 指令集

0x01 framework

➜  WebRTC.framework ls
Headers    Info.plist LICENSE.md Modules    WebRTC
➜  WebRTC.framework lipo -info WebRTC
Architectures in the fat file: WebRTC are: x86_64 i386 armv7 arm64

0x02 xcframework

➜  WebRTC.xcframework ls
Info.plist           ios-arm64_armv7      ios-x86_64-simulator
➜  WebRTC.xcframework lipo -info ios-arm64_armv7/WebRTC.framework/WebRTC
Architectures in the fat file: ios-arm64_armv7/WebRTC.framework/WebRTC are: armv7 arm64
➜  WebRTC.xcframework lipo -info ios-x86_64-simulator/WebRTC.framework/WebRTC
Architectures in the fat file: ios-x86_64-simulator/WebRTC.framework/WebRTC are: x86_64

3. 把framework 转为xcframework

原理: 先把指令集拆分,再合成

1. 拆分指令集

#  先把framrwork 拷贝到两个文件夹下边
#  我这里只需要armv7 arm64 x86_64
mkdir iphoneos iphonesimulator
➜  combineSDKDir ls
WebRTC.framework iphoneos         iphonesimulator
➜  combineSDKDir cp -R WebRTC.framework  iphoneos
➜  combineSDKDir cp -R WebRTC.framework  iphonesimulator
# 我们把 iphoneos 中的模拟器 指令集删除
➜  combineSDKDir lipo -remove i386 -remove x86_64 iphoneos/WebRTC.framework/WebRTC -o iphoneos/WebRTC.framework/WebRTC
➜  combineSDKDir lipo -info iphoneos/WebRTC.framework/WebRTC
Architectures in the fat file: iphoneos/WebRTC.framework/WebRTC are: armv7 arm64
# 再把 iphonesimulator 中的除模拟器之外的指令集删除
➜  combineSDKDir lipo -remove i386 -remove armv7 -remove arm64 iphonesimulator/WebRTC.framework/WebRTC -o iphonesimulator/WebRTC.framework/WebRTC
➜  combineSDKDir lipo -info iphonesimulator/WebRTC.framework/WebRTC
Architectures in the fat file: iphonesimulator/WebRTC.framework/WebRTC are: x86_64

2. 合成xcframework

# 使用xcodebuild 进行合成
➜  combineSDKDir xcodebuild -create-xcframework \
 -framework iphoneos/WebRTC.framework \
 -framework iphonesimulator/WebRTC.framework \
 -output "WebRTC.xcframework"
xcframework successfully written out to: /Users/jr/Documents/temp/combineSDKDir/WebRTC.xcframework

3.这样子就生成好了

把framework 转 为xcframework_第3张图片
image.png

你可能感兴趣的:(把framework 转 为xcframework)