在集成三方庫(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