Failed to create ManagedObject for coreData using Xcode 8.1. duplicate symbol OBJC_CLASS$_ClassName in: … /ClassName+CoreDataClass.o duplicate symbol OBJC_METACLASS$_ClassName in: … /ClassName+CoreDataClass.o ld: 2 duplicate symbols for architecture x86_64 clang: error: Linker command failed with exit code 1 (USe-V to see Invocation)
XCode 8 generates broken NSManagedObject subclasses for iOS 10
Option 1: “Class Definition”
Options 2: “Manual/None” Similar to Option 1, except that you can see and edit the NSManagedObject subclass files. Use the model editor to create the entities and associated attributes that you want Core Data to manage. Before using the NSManagedObject subclass generator, set the Codgen option to “Manual/None” for the entity. The Module option should be Global Namespace. After you add/remove/update an attribute, you have two choices: (1) Manually update the NSManagedObject files that were generated for you OR (2) Use the NSManagedObject subclass generator again (this will only update the Entity+CoreDataProperties.swift file). Again, if you need to override and methods from NSManagedObject, you can create an extension. The extension should be created in the Entity+CoreDataClass.swift file and not the Entity+CoreDataProperties.swift file (this file could be updated due to model editor changes). // Optional extension in Entity+CoreDataClass.swiftextension Entity { // Override NSManagedObject methods }
Option 3: “Category/Extension” Use this option if you have custom properties that do not need to be managed by Core Data. Use the model editor to create the entities and associated attributes that you want Core Data to manage. Ensure the Module option is set to Current Product Module and the Codegen option is set to “Category/Extension”. Create your own NSManagedObject subclass with the properties that you will self manage. Do not use the NSMangagedObject subclass generator. The required files are automatically generated for you by Xcode (however they do not show up in your project navigator). // Subclass NSManagedObject in Entity.swiftclass Entity: NSManagedObject { // Self managed properties } // Optional extension in Entity.swiftextension Entity { // Override NSManagedObject methods }