创建同时支持真机和模拟器的framework

2018-12-28  本文已影响12人  herui201211

使用到一个命令: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库为例:

待编译成功后找到Products->IJKmediaFramework.framework文件,右键 -> Show in Finder,查看上一级目录如下:

这当中便是刚才生成的库文件了,紧接着祭出终端,输入命令

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 
上一篇 下一篇

猜你喜欢

热点阅读