I've suddenly been tripped up by a bizarre issue. I have a rather extensive CoreData data model, and I've copied it (and the project containing it) over to a new project for a prototype that I'm working on. I got it working, and was mixing and matching new entities and attributes.
Suddenly, and for no apparent reason, I'm suddenly getting the following error:
'NSInternalInconsistencyException', reason: '+entityForName: could not locate an entity named 'DocumentLocations' in this model.'
I dug into the whole process for creating the NSManagedObjectContext, NSPersistentStoreCoordinator, and NSManagedObjectModel, and have gotten to the point where it's pretty clear that the object model is not being loaded. I execute the following command:
_managedObjectModel = [[NSManagedObjectModel mergedModelFromBundles:nil] retain];
But when I look for the entities in the model after loading (this method creates the model from the main bundle if you pass nil to mergedModelFromBundles), nothing's there.
It appears that my xdatamodel file is not being seen by Xcode or the Simulator. And I have absolutely no idea why not. I'm going to try to force the issue by explicitly loading it through a URL, but I'm not sure how that's going to work.
Any clues? CoreData issues can be absolutely baffling. I've managed to work my way through most of them over time, but this one's a head-scratcher.
Edit: Alex figured it out. I'm only left with wondering how the model got removed from the 'Compile Sources' list in Xcode. Wish Xcode were more reliable. Can really be a PITA.