Maha
Maha

Reputation: 529

duplicate symbols for architecture armv7 Error

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

Upvotes: 0

Views: 5811

Answers (3)

Joe M
Joe M

Reputation: 677

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

Upvotes: 0

Alan Glasby
Alan Glasby

Reputation: 291

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.

Upvotes: 28

Buntylm
Buntylm

Reputation: 7363

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.

Upvotes: 0

Related Questions