使用到一個(gè)命令:lipo
生成兼容文件
lipo -create '真機(jī)庫文件' '模擬器庫文件' -output '生成的文件'
lipo -info
//查看庫文件信息
真機(jī): Architectures in the fat file: xxx.framework/xxx are: armv7 arm64
模擬器:Architectures in the fat file: xxx.framework/xxx are: i386 x86_64
為了更直觀地描述這一過程弊知,下面以IJKPlayer項(xiàng)目生成framework庫為例:
打開IJKMediaDemo.xcodeproj
edit scheme -> Build configuration 選擇 Release -> Close
scheme選擇IJKmediaFramework 蕾羊,運(yùn)行設(shè)備選擇真機(jī)或Generic iOS Device
Command + B
編譯成功后,切換運(yùn)行設(shè)備選擇任一模擬器
Command + B
待編譯成功后找到Products->IJKmediaFramework.framework文件,右鍵 -> Show in Finder,查看上一級(jí)目錄如下:
- Release-iphoneos
- Release-iphonesimulator
這當(dāng)中便是剛才生成的庫文件了,緊接著祭出終端蚜印,輸入命令
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
若一切順利,此時(shí)桌面會(huì)生成IJKMediaFramework文件
lipo -info ~/Desktop/IJKMediaFramework
看到如下輸出則表明大功告成留量,庫文件可同時(shí)支持多種cpu架構(gòu)i386 armv7 x86_64 arm64
Architectures in the fat file: ~/Desktop/IJKMediaFramework are: i386 armv7 x86_64 arm64