使用到一个命令:lipo
生成兼容文件
lipo -create '真机库文件' '模拟器库文件' -output '生成的文件'
lipo -info
//查看库文件信息
真机: Architectures in the fat file: xxx.framework/xxx are: armv7 arm64
模拟器:Architectures in the fat file: xxx.framework/xxx are: i386 x86_64
为了更直观地描述这一过程,下面以IJKPlayer项目生成framework库为例:
打开IJKMediaDemo.xcodeproj
edit scheme -> Build configuration 选择 Release -> Close
scheme选择IJKmediaFramework ,运行设备选择真机或Generic iOS Device
Command + B
编译成功后,切换运行设备选择任一模拟器
Command + B
待编译成功后找到Products->IJKmediaFramework.framework文件,右键 -> Show in Finder,查看上一级目录如下:
- Release-iphoneos
- Release-iphonesimulator
这当中便是刚才生成的库文件了,紧接着祭出终端,输入命令
lipo -create ~/Library/Developer/Xcode/DerivedData/IJKMediaDemo-xxx/Build/Products/Release-iphonesimulator/IJKMediaFramework.framework/IJKMediaFramework ~/Library/Developer/Xcode/DerivedData/IJKMediaDemo-xxx/Build/Products/Release-iphoneos/IJKMediaFramework.framework/IJKMediaFramework -output ~/Desktop/IJKMediaFramework
若一切顺利,此时桌面会生成IJKMediaFramework文件
lipo -info ~/Desktop/IJKMediaFramework
看到如下输出则表明大功告成,库文件可同时支持多种cpu架构i386 armv7 x86_64 arm64
Architectures in the fat file: ~/Desktop/IJKMediaFramework are: i386 armv7 x86_64 arm64