Been having my first crack at Core Data and I\'m getting the following error when running my code on my device, but it works fine on the simulator..
*
For me the problem was due to the fact that I copy pasted my model from a sandbox project to my actual project. Always make sure to generate your model from within the project that the model is being used.
I had this problem and changing "moms" to "mom" didn't do anything. To fix it I had to right click on the xcdatamodelId file > show package contents then delete the hidden .xcurrentversion file.
P.S: This problem only started happening after I'd changed the name of the data model file.
I had the same problem, it worked fine on iOS6 but not on iOS5. This is how I solved it:
.xcdatamodeld
, open the Editor menu and click "Add Model Version...").xcdatamodeld
under Versioned Core Data Model).xcdatamodeld
file in xcode.xcdatamodeld
file in Finder and choose "Show Package Contents".xcdatamodel
that you dont want.xcdatamodeld
in xcode(This is where I found how to delete a Model version: How to delete an old/unused Data Model Version in Xcode)
After I fixed the naming issue, the error remained. Then it worked after restarting Xcode 5. This might automatically do the same thing as some of the manual linking suggestions offered here.
I had the same issue, i.e.
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"MyModel" withExtension:@"momd"];
returned nil, because there was no .momd file generated.
The reason was that in the app directory (e.g. MyGreatApp/MyGreatApp.app) xcode had copied the MyModel.xcdatamodeld instead of generating the MyModel.momd from the MyModel.xcdatamodeld file (using momc).
The solution was to delete the reference to MyModel.xcdatamodeld inside the XCode project browser and drag it back into the project from the finder. After that xcode realized it needed to compile it to a .momd.
The solution to the problem you speak of is simple. Change the file extension to "mom" instead of "momd" in the model URL. Done.