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

使用到一个命令: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 
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容