創(chuàng)建同時(shí)支持真機(jī)和模擬器的framework

使用到一個(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,查看上一級目錄如下:

  • 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 
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容