duplicate symbols for architecture arm64 after xCode 8.0 update

背景描述:項(xiàng)目升級(jí)到xcode 8 后,遇到了一些問(wèn)題,做下記錄,以供大家參考;
問(wèn)題一:Swift 2.3 升級(jí)到 swift 3.0 的問(wèn)題
PS:我是在OC項(xiàng)目中遇到的,靜態(tài)庫(kù)沖突
解決方案:
1,舊項(xiàng)目,使用xcode8打開時(shí),會(huì)自動(dòng)詢問(wèn),是否自動(dòng)將 swift2.3語(yǔ)法,升級(jí)到swift3.0;可以選擇轉(zhuǎn)換,轉(zhuǎn)換之后,如果還有報(bào)錯(cuò)的地方,需要自己手動(dòng)處理swift語(yǔ)法錯(cuò)誤;
2,如果不升級(jí)swift語(yǔ)法,可以在build setting 中,設(shè)置Use Legacy Swift Language Version 為YES;即:允許使用低版本swift;
問(wèn)題二:項(xiàng)目編譯期間,報(bào)符號(hào)重定義的錯(cuò)誤:duplicate symbols

解決方案:
1,Build Setting 中,設(shè)置NO Common Blocks 為NO; 【該選項(xiàng)的意思,官方解釋如下】
In C, allocate even uninitialized global variables in the data section of the object file, rather than generating them as common blocks. This has the effect that if the same variable is declared (without extern ) in two different compilations, you will get an error when you link them. The only reason this might be useful is if you wish to verify that the program will work on other systems which always work this way.
2,如果1不起作用,繼續(xù)Build Setting 中,設(shè)置Enable Testability 為NO;【該選項(xiàng)的意思,解釋如下】(或者查看重定義的符號(hào),是否聲明為了static 類型)

From The Xcode 8 Release Notes:
When the Enable Testability build setting is enabled, Xcode 8 will pass -export_dynamic to the linker to preserve all global symbols for testing. This effectively overrides dead code stripping, which can expose link failures from unused functions that reference undefined symbols. If necessary, disabling testability will allow the link to proceed without source changes. (27684883)
Of course, the best thing to do is to either: a) remove the unused code that is causing the linker issues, or b) actually fix the linker issues.

在用oc語(yǔ)言寫的項(xiàng)目中親測(cè)可用,在這附上原文地址http://blog.csdn.net/jiajiayouba/article/details/52766600
十分感謝原創(chuàng)作者

最后編輯于
?著作權(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)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

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

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