Maha Maha - 2 months ago 32
Swift Question

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

Answer

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.