問題:
編譯器報錯:duplicate symbols for architecture arm64
出現(xiàn)在 本來是用xcode7之前創(chuàng)建的工程 升級到xCode 8.0 update
解決:
Common Blocks 和 Testability 都設(shè)置為NO
原因:
1、在導(dǎo)入的SDK里有的頭文件聲明了公共變量受神,然后在另外幾個文件里import了這個頭文件抠忘,No Common Blocks默認為YES暂吉,編譯器就報錯了色洞。
官方的解釋是:
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勋乾、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.
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.