I was trying to create NSManagedObject subclasses (2 related entities) automatically in Xcode. They are generated like this:
You should delete all these entities, change "Codegen" settings to "Manual/None" for them in Data Model Inspector, and generate entities again. It works good! You don't need to remove +CoreDataClass.h files from Compile Source. You don't need to mark entities as abstract. You don't need to generate classes by yourself. You should change only "Codegen" settings and regenerate entities automatically.
Edit: Thanks to some help from @iPeter, found the following:
After doing Editor > Generate NSManagedObject files, if you trash the files BEFORE building, your project should build no problems.
Then #import "myManagedObjectName+CoreDataClass.h" (where the MO name is the one in the entity inspector in core data) into any classes where you require those Managed Objects.
In other words, you don't require any of the actual ManagedObject files in your folder. Xcode keeps the generated ones in your Derived Data folder.
If for some reason you need those files to remain in your file directory, the following workaround will work. Go to your Target and delete the CoreDataClass sources in your Compile Sources.
Leaving you with this:
Just wrote a blog post that includes this info for anybody interested.
If you do not generate managed object subclass automatically, then don't forget to check "Codegen" settings for an Entity in Data Model Inspector:
late post ... but for me was simply a copy paste of an entity, Xcode does not seem to change the original class name associated with the entity (observed on Xcode 9.0.1)
I recently tried the above answer and it failed. Somehow, Xcode was still generating the files.
I solved it using the following method:
This sounds like a bug in Xcode...
You need to remove the CoreData related sub class generated by yourself, and you can keep the #import line with those classes, now all those files will be generated automatically when build the project.