不同第三方庫(kù)重復(fù)存在某一文件解決方案

在集成三方庫(kù)的時(shí)候出現(xiàn)了兩個(gè)庫(kù)文件沖突的問(wèn)題。百度單號(hào)識(shí)別OCR與百度人臉識(shí)別SDK中均包含報(bào)錯(cuò)的同一個(gè)文件。解決方案就是需要拆分一個(gè)庫(kù),把這個(gè)庫(kù)中的沖突文件刪除然后重新生成即可。具體如下:

拆分以libTradingSystem.a靜態(tài)庫(kù)操作為例,沖突文件以Utils.o文件為例

1、首先檢查lib架構(gòu),命令行輸入:

lipo -info /Users/liuxh/Desktop/lib/libTradingSystem.a

輸出結(jié)果如下,可以看到lib庫(kù)支持的架構(gòu)有哪些。

2、依次拆分libTradingSystem.a架構(gòu) ,下面以amv7架構(gòu)拆分為例,其他架構(gòu)的需要一樣操作。

lipo /Users/liuxh/Desktop/libTradingSystem.a -thin armv7 -output /Users/liuxh/Desktop/libTradingSystem_armv7.a

對(duì)libTradingSystem.a這個(gè)庫(kù),同時(shí)需要拆分x86_64、arm64。

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

可以在output 對(duì)應(yīng)的路徑下看到下圖文件:


3、選擇有沖突的架構(gòu)(庫(kù)文件沖突的時(shí)候在xcode中會(huì)顯示是在哪種架構(gòu)沖突),找到架構(gòu)內(nèi)的沖突文件。

Ar -t /Users/liuxh/Desktop/lib/libTradingSystem_arm64.a

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

4、移除沖突文件

Ar-dv/Users/liuxh/Desktop/lib/libTradingSystem_arm64.a Utils.o

//沖突文件有多個(gè)可以這樣寫

Ar-dv/Users/liuxh/Desktop/lib/libTradingSystem_arm64.a Utils.o Utils.o Utils.o Utils.o

5、重新合并靜態(tài)庫(kù)

lipo -create /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

完成以上操作大功告成了,把重新合并的庫(kù)替換進(jìn)工程中就可以完美build了!??!

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

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

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