问题描述:
duplicate symbol _OBJC_CLASS_$_Person in:/Users/suruikeji/Library/Developer/Xcode/DerivedData/CoreData_Demo-gwbqmxvuoisdjsekqjhmlknqktgk/Build/Intermediates/CoreData_Demo.build/Debug-错误信息:iphonesimulator/CoreData_Demo.build/Objects-normal/x86_64/Person+CoreDataClass.o
duplicate symbol _OBJC_METACLASS_$_Person in:/Users/suruikeji/Library/Developer/Xcode/DerivedData/CoreData_Demo-gwbqmxvuoisdjsekqjhmlknqktgk/Build/Intermediates/CoreData_Demo.build/Debug-iphonesimulator/CoreData_Demo.build/Objects-normal/x86_64/Person+CoreDataClass.o
ld: 2 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
根据信息说Person+CoreDataClass.o文件重复了。
这是因为在Xcode8.0中包含了一个自动生成NSManagedObject的机制,如果你打开该机制则会在project(Derived Data目录中)实际生成的DerivedSources文件夹中出现同名的源代码文件。
按一下方法解决:
1.打开在model file的inspector,选择Tools Version为 Xcode 7.3
2.或者你可以根据不同的entity去分别选择启用还是关闭自动生成机制;选择model file中特定的entity,打开其Data Model Inspector窗口,将其中的Codegen选项设置为Manual/None: