6

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?

ChikabuZ
  • 10,031
  • 5
  • 63
  • 86
Meeko
  • 85
  • 2
  • 6
  • It normally happens when you have multiple files, may be you have added a external framework, plus you have added the source too. – iphonic Aug 04 '14 at 17:12
  • @iphonic So I just looked and it says my duplicate symbols are in my framework and are all output files but I am not sure how to fix this. Any idea what I should do? – Meeko Aug 04 '14 at 18:10

3 Answers3

6

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!

Adam Evans
  • 2,072
  • 1
  • 20
  • 29
4

There are certain Files in your project which may have been imported twice, try to analyse the error log, it must be referring the file where somewhere you must be getting an error as "YourViewCOntroller.O" its finding the double files,search for "YourViewCOntroller" in your project navigator, You need to remove these files from your Xcode project and then build again

Geet
  • 2,427
  • 2
  • 21
  • 39
  • 1
    So I just looked and it says my duplicate symbols are in my framework and are all output files but I am not sure how to fix this. Any idea what I should do? – Meeko Aug 04 '14 at 18:10
  • If you are using Cordova - check out my answer below. I started out removing those files. But it is tedious work - and it occurred to me that my files all had to do with my cordova-email plugins. so.... see below for my answer. – Sandi Laufenberg-Deku Nov 28 '17 at 22:23
0

If you are using Cocoapods like me, you may find that the other answers are not helping, because the duplicates are generated by the pod file automatically.

What worked for me was to look at the list of duplicate symbols, for example:

duplicate symbol _OBJC_METACLASS_$_AFImageCache in:

___/Build/Products/Debug-iphoneos/libPods-AFNetworking.a(UIImageView+AFNetworking.o)

___/Build/Products/Debug-iphoneos/libAFNetworking.a(UIImageView+AFNetworking.o)

ld: 214 duplicate symbols for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Then go to your project/target Build Settings -> Other Linker Flags and remove the reference to the duplicate pod (In my case, AFNetworking).

Clean, build again and it should work.

--

As far as I can tell, this may be happening because one of the other pods references AFNetworking, leading to a duplicate.

Jacques.S
  • 3,262
  • 2
  • 21
  • 27