ld: xx duplicate symbols for architecture armv7 Xcode Project

Meeko picture Meeko · Aug 4, 2014 · Viewed 7.7k times · Source

Hi everybody I have a Xcode project that gives me this error every time I try to build the project:

ld: xx duplicate symbols for architecture armv7 Xcode Project clang: error: linker command failed with exit code 1...

I have googled around and most solutions say to get rid of duplicate files in the build phase->Compile Resources section of the project or to change the import .m to .h in some files. Problem is the list of compiled resources isn't even sorted and I do not even know which files to fix since there are a lot of files in my project. Any advice on how on how to clean this up?

Answer

Adam Evans picture Adam Evans · Aug 4, 2014

I have had this error sometimes, and the issue is always this. I have a static variable in the .m of one class, and another static variable with the same name in another .m. Apparently the compiler does not like it when there are two static variables with the same name, whether in different files or not. So check for any duplicate static variable names or #define macros. Also, it might not be duplicate files or files imported twice. If two different files are imported, but each has a variable or macro with the same name, there will be an error because the compiler can't figure out which one to use. The conflicting variables should be in the files mentioned in the error. Hope this helps!