Having problems with Core Data?

When I add new entities, they dissappear after a while from the .xcdatamodeld file. Further, Xcode sometimes generate a third file when creating the NSManagedObject Subclass, containing some kind of macro that crashes the build. It looks like it is a template issue gone bad.

I have submitted rdar://2681978

Replies

Super helpful. Thanks. I trashed my Data Model, created a new one and in the file inspector for the model set it to Objective C.


From there, I just used Create NSManagedObject subclass in Editor. That added the files as extensions to my project. Simply import the one for the class file and that did 'er.


Thanks again!

I had the same issue on XCode 8.2.

Finally figured out that it seems some "smart" or default setting for coredata in XCode 8.

Goto your coredata file and select the entity, change "Codegen" under class section from "Class Definition" to "Manual/None" and save.

REMEMBER: change ALL the "Codegen" setting for ALL your model.

Then, goto "Build Phases" setting of your project, add the generated model class files (include extensions) to "Compile Sources" section.

I have resolved this by these steps.

The "smart" default setting just unbelievable.

I had a slightly different issue: I changed my core data model and deleted the datastore since I was importing data from a Rails API. The compiler would complain about missing files, often different files wtih each compile. The first time I changed it, I was able to fix it with option clean. The second time, that didn't work. I followed the first part of Danial's fix (i.e., change codegen) and it compiled cleanly. I'm running Xcode 8.2.1