0

I have an old class "Approval.swift" in my swift project

I added NSManagedObject (Approval) in Core Data and i create NSManagedObject subclass with the same name (Approval.swift) for that entity

Then i changed the Entity name to "ApprovalObject" and the associated class to ApprovalObject.swift to differentiate it from the old class "Approval.swift"

When i tried to run the project, i got this error

duplicate symbol _OBJC_METACLASS_$_Card in: /Users/MyUser/Library/Developer/Xcode/DerivedData/MyProject-czluntwgoefegbeilusmojsyejlc/Build/Intermediates/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/armv7/ApprovalObject.o /Users/MyUser/Library/Developer/Xcode/DerivedData/MyProject-czluntwgoefegbeilusmojsyejlc/Build/Intermediates/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/armv7/Card.o duplicate symbol _OBJC_CLASS_$_Card in: /Users/MyUser/Library/Developer/Xcode/DerivedData/MyProject-czluntwgoefegbeilusmojsyejlc/Build/Intermediates/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/armv7/ApprovalObject.o /Users/MyUser/Library/Developer/Xcode/DerivedData/MyProject-czluntwgoefegbeilusmojsyejlc/Build/Intermediates/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/armv7/Card.o

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

Can someone help me in solving this error? Thanks a lot

pnuts
  • 58,317
  • 11
  • 87
  • 139
Maha
  • 519
  • 2
  • 11
  • 23

3 Answers3

28

I was getting the same type of error with a newly created app under Xcode 8. After much investigation I found reference to entries under Build Phases -> Compile Sources where I found that the data model was included in addition to the .m files. Removing this cleared the error and the app now builds and functions correctly.

Alan Glasby
  • 291
  • 3
  • 5
  • Splendid! All other answers kept mentioning to look for duplicated .m files, you pointed out the data model file. I wasted 3 hours looking for the ghost .m file. – Rick Oct 31 '16 at 13:39
  • 1
    Shitfire. What kind of QC at Apple let's this crap get through? Thx for this answer, it marked an end to 2 hours of wasted time. – LJ Wilson Nov 07 '16 at 19:28
  • You are a genus!!! after hours of searching, finally sovled my problem!!! Other answers are making non sense, your answer is right!!! – user2053760 Nov 23 '16 at 16:36
  • Cant thank you enough. I wasted 4 hours looking for an answer.Thank you. – Sekhar Dec 18 '16 at 16:29
  • Thanks you save my day! – Zigii Wong Mar 02 '17 at 07:44
0

Duplicate symbols for architecture mainly reason is you have added the same .m or .o file twice into your project. For resolving the issue just check the linker error like in your case its showing ApprovalObject. Then just go build phases then compile sources and search the specified file.

Buntylm
  • 7,345
  • 1
  • 31
  • 51
0

I got the above build error because I imported a .m file instead of a .h file in another .m file

Joe M
  • 669
  • 6
  • 9