duplicate symbols for architecture arm64 after xCode 8.0 update

问题:
编译器报错:duplicate symbols for architecture arm64
出现在 本来是用xcode7之前创建的工程 升级到xCode 8.0 update
解决:
Common Blocks 和 Testability 都设置为NO

duplicate symbols for architecture arm64 after xCode 8.0 update_第1张图片
屏幕快照 2017-03-03 下午3.33.18.png
duplicate symbols for architecture arm64 after xCode 8.0 update_第2张图片
屏幕快照 2017-03-03 下午3.31.40.png

原因:
1、在导入的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.

你可能感兴趣的:(duplicate symbols for architecture arm64 after xCode 8.0 update)