解決Three20與其他framework衝突的辦法

來源:互聯網
上載者:User

項目中用到Three20架構,同時也使用了訊飛語音的framework,編譯時間出現類似如下衝突提示資訊:

ld: duplicate symbol _OBJC_CLASS_$_AdLinks in /Users/w/Documents/project 2/dianxing_v2.00_code_reconfiguration/iFlyLib/iFlyTTS.framework/iFlyTTS(AdvertiseDataDefine.o) and /Users/w/Documents/project 2/dianxing_v2.00_code_reconfiguration/iFlyLib/iFlyISR.framework/iFlyISR(AdvertiseDataDefine.o)
for architecture i386
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang failed with exit code 1

網上收集了一下對於該問題的解答,感覺還比較靠譜,粘貼如下:

個人猜想,大概是在iFlyTTS和iFlyISR在編譯的時候,都加入了AdvertiseDataDefine.m(AdvertiseDataDefine.o)這個檔案,而裡麵包含了AdLinks這個類的category。在一般的連結參數下倒是沒有問題(因為category的連結被忽略了),但是如果引入了Three20,於是就加入了-ObjC - all_load這個參數(沒辦法,這個參數對於Three20的運行時必須的),於是這個連結錯誤就表現出來了(於是連結時就出現了duplicate symbol
_OBJC_CLASS_$_AdLinks in iFlyTTS(AdvertiseDataDefine.o) and iFlyISR(AdvertiseDataDefine.o) for architecture XXXX)。

解決方案:修改連結參數(Other Linker Flag)
1.去掉-ObjC -all_load參數(這個參數會強制所有的靜態連結庫都載入其中的category);
2.改為逐一載入Three20的各個靜態庫,即修改連結參數(Other Linker Flag)為如下形式:

-force_load $(BUILT_PRODUCTS_DIR)/libThree20.a 
-force_load $(BUILT_PRODUCTS_DIR)/libThree20UINavigator.a 
-force_load $(BUILT_PRODUCTS_DIR)/libThree20UICommon.a 
-force_load $(BUILT_PRODUCTS_DIR)/libThree20UI.a 
-force_load $(BUILT_PRODUCTS_DIR)/libThree20Style.a 
-force_load $(BUILT_PRODUCTS_DIR)/libThree20Network.a 
-force_load $(BUILT_PRODUCTS_DIR)/libThree20Core.a

ps:寫這篇文章主要目的是為了說明,在碰到Three20和其他framework衝突的時候,可以考慮一下逐個載入Three20的lib,而不是使用-ObjC - all_load參數一次性強制加入。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.