Error: duplicate symbols for architecture armv7 af

2019-06-22 23:44发布

问题:

I have an app using core data framework. I was working fine. I just changed the data model - add an attribute to one entity. And when I try to build it, I got an error:

duplicate symbol _OBJC_METACLASS_$_AccountFolder in:
/Users/XXX/Library/Developer/Xcode/DerivedData/MyApp-bxsswgxdenxgjweotkkkckaoalat/Build/Intermediates/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/armv7/AccountFolder-33D7EA63E98D6090.o

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

I did some search, and most people getting this error is from mistyping .h to .m, or import same .h several times. I checked my code. I don't have that. And the coredata framework is still there.

Does anyone know what else can be the reason? Thanks.

回答1:

Check if there are multiple NSManagedObject subclass files generated after making this change. There should be duplicate files generated after your attribute change. Check in finder window as well as in project and then remove the duplicate files. That should fix this issue.