在集成三方庫的時候出現(xiàn)了兩個庫文件沖突的問題。百度單號識別OCR與百度人臉識別SDK中均包含報錯的同一個文件。解決方案就是需要拆分一個庫,把這個庫中的沖突文件刪除然后重新生成即可。具體如下:
拆分以libTradingSystem.a靜態(tài)庫操作為例,沖突文件以Utils.o文件為例
1、首先檢查lib架構(gòu),命令行輸入:
lipo -info /Users/liuxh/Desktop/lib/libTradingSystem.a
輸出結(jié)果如下,可以看到lib庫支持的架構(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
對libTradingSystem.a這個庫,同時需要拆分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 對應(yīng)的路徑下看到下圖文件:
3、選擇有沖突的架構(gòu)(庫文件沖突的時候在xcode中會顯示是在哪種架構(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
//沖突文件有多個可以這樣寫
Ar-dv/Users/liuxh/Desktop/lib/libTradingSystem_arm64.a Utils.o Utils.o Utils.o Utils.o
5、重新合并靜態(tài)庫
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