2 duplicate symbols for architecture x86_64
导入CoreData class后出现编译报错
**NewsCache+CoreDataClass导入后编译出错
duplicate symbol OBJC_CLASS$_EC_Audio in:
/Users/ryan/Library/Developer/Xcode/DerivedData/AudioRecorder-fynbzrptektfqnalzdkspcoejrvg/Build/Intermediates/AudioRecorder.build/Debug-iphonesimulator/AudioRecorder.build/Objects-normal/x86_64/ NewsCache+CoreDataClass.o
duplicate symbol OBJC_METACLASS$_EC_Audio in:
/Users/ryan/Library/Developer/Xcode/DerivedData/AudioRecorder-fynbzrptektfqnalzdkspcoejrvg/Build/Intermediates/AudioRecorder.build/Debug-iphonesimulator/AudioRecorder.build/Objects-normal/x86_64/ NewsCache+CoreDataClass.o
ld: 2 duplicate symbols for architecture x86_64
解决办法:
一、删除掉自己创建的NSManagedObject SubClass类,因为在托管对象中创建Entity属性后会自动生成对应的类,如果自己再手动创建就会导致重复。Build工程之后,引用的时候直接#import "EntityName+CoreDataClass.h"就可以了。
二、如果想保留自己创建的类,Build Settings ->Complie Source中移除对应的.m文件。或者参照方法三:
三、.xcdatamodeld 中选择Entity-class-codegen-manual/none即可,如下图: