编译报错:Duplicate Symbols for Architecture arm64

以下方法都非常容易排查,可以依次参考。
1.查看报错信息中的文件,直接在工程左侧文件目录中搜索。


这个没什么难度

2.检查是否在#import头文件的时候,不小心把.h写成了.m。

3.查看被编译的文件中是否有重复的(如果有文件显示红色一般是编译器没有找到的文件)。
进入Target->Build Settings->Compile Sources下,查看是否有异常文件。



4.进入Target->Build Settings->Apple LLVM 8.0-Code Generation下,将No Common Blocks设置为NO。



“NO Common Blocks”是什么呢?

 官方的解释是:

    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.

    如果同一个变量被声明(没有extern)放在两个不同的汇编,当你将它们链接时将会得到一个错误。

猜你喜欢

转载自blog.csdn.net/mscinsidious/article/details/56676086