iOS 解決三方庫文件沖突的方法

最近項目里在集成三方庫的時候出現(xiàn)了兩個庫文件沖突的問題。A庫的靜態(tài)包里 包含了util.o文件 B庫是個動態(tài)庫,也包含了個util.o文件。拆分刪掉了A庫里的沖突文件并重新生成了A庫,解決了問題,記錄下解決方案,以作后用。

步驟流程(libTradingSystem.a為例)

打開命令行工具:

1、檢查lib架構(gòu)
lipo -info /Users/liuxh/Desktop/lib/libTradingSystem.a 

輸出結(jié)果為:


image.png
2、依次拆分libTradingSystem.a架構(gòu) (如果有amv7s架構(gòu)也跟下面操作一樣)
lipo /Users/liuxh/Desktop/libTradingSystem.a -thin armv7 -output /Users/liuxh/Desktop/libTradingSystem_armv7.a
lipo /Users/liuxh/Desktop/lib/libTradingSystem.a -thin x86_64 -output /Users/liuxh/Desktop/lib/libTradingSystem_x86_64.a
lipo /Users/liuxh/Desktop/lib/libTradingSystem.a  -thin arm64 output /Users/liuxh/Desktop/lib/libTradingSystem_arm64.a

得到四個文件,如圖:


image.png
3、選擇有沖突的架構(gòu),找到架構(gòu)內(nèi)的沖突文件
 Ar -t /Users/liuxh/Desktop/lib/libTradingSystem_arm64.a

查詢結(jié)果如下圖所示(沖突文件為arm64架構(gòu)下的Utils.o文件)


image.png
4、移除沖突文件
Ar -dv /Users/liuxh/Desktop/lib/libTradingSystem_arm64.a Utils.o
//沖突文件有多個可以這樣寫
Ar -dv /Users/liuxh/Desktop/lib/libTradingSystem_arm64.a Utils.o  Utils.o Utils.o Utils.o
5、重新合并靜態(tài)庫
lipo -creat /Users/liuxh/Desktop/lib/libTradingSystem_arm64.a  /Users/liuxh/Desktop/lib/libTradingSystem_armv7.a  /Users/liuxh/Desktop/lib/libTradingSystem_x86_64.a  -output /Users/liuxh/Desktop/lib/libTradingSystem.a 
6、用新生成的靜態(tài)庫替換掉老庫

至此,整個流程完成。沖突問題解決~

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

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

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