Invalid redeclaration on CoreData classes Invalid redeclaration on CoreData classes ios ios

Invalid redeclaration on CoreData classes


This is because Xcode handles all that by itself. I felt it like a bit of trouble as the auto generated classes don't have all my properties.

So follow these steps to get this as it used to be:

  • Delete what ever classes you already made for core data.
  • Set class.Module as Current Product moduleenter image description here

  • Set Class.codegen as Manual/None

enter image description here

  • Now select your entity and create NSmanagedobject subclassenter image description here

  • You are all set


From Apple : Whats new in Core Data

Xcode automatic subclass generation

Xcode now supports automatic generation of NSManagedObject subclasses in the modeling tool. In the entity inspector:

Manual/None is the default, and previous behavior; in this case you should implement your own subclass or use NSManagedObject. Category/Extension generates a class extension in a file named like ClassName+CoreDataGeneratedProperties. You need to declare/implement the main class (if in Obj-C, via a header the extension can import named ClassName.h). Class Definition generates subclass files named like ClassName+CoreDataClass as well as the files generated for Category/Extension.

The generated files are placed in DerivedData and rebuilt on the first build after the model is saved. They are also indexed by Xcode, so command-clicking on references and fast-opening by filename works.

You don't need to manually create subclasses for NSManagedObjects.

I would suggest that you delete the files that you created with NSManagedObjects (Move them to Trash) and go to every entity in the DataModel Inspector under Codegen select : Manual / None and create than the Subclasses.