Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate symbols for architecture x86_64 under Xcode

For me, changing 'No Common Blocks' from Yes to No ( under Targets->Build Settings->Apple LLVM - Code Generation ) fixed the problem.


Stupid one, but make sure you haven't #imported a .m file by mistake somewhere


75 duplicate symbols for architecture x86_64

Means that you have loaded same functions twice. As the issue disappear after removing -ObjC from Other Linker Flags, this means that this option result that functions loads twice:

from Technical Q&A

This flag causes the linker to load every object file in the library that defines an Objective-C class or category. While this option will typically result in a larger executable (due to additional object code loaded into the application), it will allow the successful creation of effective Objective-C static libraries that contain categories on existing classes.

https://developer.apple.com/library/content/qa/qa1490/_index.html


In my case, I just created a header file to define constant strings like this:

NSString *const AppDescriptionString = @"Healthy is the best way to keep fit";

I solved this scenario by using static:

static NSString *const AppDescriptionString = @"Healthy is the best way to keep fit";

Happens also when you declare const variables with same name in different class:

in file Message.m

const int kMessageLength = 36;

@implementation Message

@end

in file Chat.m

const int kMessageLength = 20;

@implementation Chat

@end

I have same problem. In Xcode 7.2 in path Project Target > Build Setting > No Common Blocks, i change it to NO.