I renamed my project.. and step by step I renamed all the targets, AppDelegate classes etc. Anyway it builds now but crashes as it can’t find the .momd in the below code:
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"MyApp" withExtension:@"momd"];
How do I get it to ‘refresh’ or build this momd file again? I have read various potential solutions involving adding a version on the .xdatamodeld file but heres the other thing.
When I click on the .xdatamodeld file it doesn’t open up the editor anymore. It just does nothing. Right click bring me zero options.
I tried deleting the xdatamodeld file and creating a new one, but it has the same problem. When I press on it it doesn’t open the editor.
When I create a brand new core data xcode project template, it does open the editor when I press on it. What am I doing wrong here?
I’m still using Xcode 3, but when I double-click an .xdatamodeld file, it just opens the organizer. If I double-click an .xdatamodel file, it launches the project. This is probably because the xdatamodeld a folder, not a single file. It sounds like your problem is that the project file has lost its tracking to the mom you’re using.
Here are some notes I made during past troubleshooting:
– First, is the current xcdatamodel, the one with the green check icon, the first one? If not, drag it into first place, then test the app again.
– In Finder, make a copy of your xcdatamodel elsewhere for safekeeping.
– Get rid of the xcdatamodeld, in Finder and/or Xcode (I’m not sure which order I did this in). When done, it should not appear in Xcode.
– Drag the xcdatamodel (the one in the project folder) from the Finder to Xcode’s Groups & Files pane for the project, and choose the option that makes a copy for the project.
– Select the xcdatamodel, Design>DataModel>AddModelVersion. Now you should have a new xcdatamodeld file.
– Run the test again, doing the gdb print object command at breakpoint. Hopefully you’ll get a nice long printout, representing your data model.
– In future, avoid grouping the xcdatamodel/d files into a folder in Xcode. That seems to confuse things.
These are actually folders in disguise, as you will see if you remove their extensions. The guts of the data model is a plist, which you can open by double-clicking.
If you do this, test your app afterward and make sure it is still able to access your database. If not, follow the steps above.