Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate Symbol Error in Objective-C build?

You could also get this error if you mistakenly let Xcode's auto-complete for #import statements specify the '.m" file for the 'duplicate' class instead of the '.h'.


It seems that you are compiling the same BlogTableItemCell class two times in different places of your code. This may happen in the following cases.

  • You have put the same class implementation into two different files;

  • You actually have just one implementation of this class, however you are also linking in your project a framework or library containing a class whose name is exactly the same of yours.

Try finding in the whole project your class and make sure only one copy is available within your project.


For me, changing 'No Common Blocks' from Yes to No ( under Targets->Build Settings->Apple LLVM - Code Generation ) enter image description here


I had a similar problem due to poor defining of consts. I had defined a const in my header:

int const kCropLocationTop = 1;

This was presumably imported multiple times. To fix i changed the header def as follows:

extern int const kCropLocationTop;

and moved the assigning of the const to the .m file:

int const kCropLocationTop = 1;

Hope that helps anyone who's as ignorant of simple objective c concepts as I am!


iPhone: Duplicate Symbol Error? by user576924

answered it correctly for me. However to find the offending gremlin this ZSH snippet.

grep "import.*\.m" **/*.[hm]

Will immediately tell you where your error is.


By mistake the source file was included twice in the Project -> Build Phase -> Compile Sources. Removing one of them solved the problem.