Can't edit xcdatamodeld in xcode4 momb
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 sam开发者_JAVA百科e 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 re-added the .xcdatamodeld file to my project and deleted the old reference. Works again now.
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:
- Troubleshooting dbase access — getting the right mom:
- The first thing to suspect is that the managedObjectContext is not pointing to the correct data model (or managed object model, “mom”). (Actually, you are probably using the type:@“momd”, but it’s the target mom that’s been lost.)
- In your app delegate, look for the accessor method managedObjectModel (created by Xcode when you stipulated Core Data store upon creating the project). Put a breakpoint in this method at the line that returns the mom.
- Execute the program, and when it hits the breakpoint, go to the debugger model, and type “po” followed by the name of the mom variable being returned. (This is gdb’s “print object” command.)
- What prints out will include “entities {” followed by a description of the entities in your data model. If nothing follows the brace, a blank mom is being returned — you’re not accessing the correct data model.
- If clicking on the xcdatamodel in Xcode shows the full data model as expected, is it enclosed in an xcdatamodeld? That’s a sort of bundler/router/path file, and it may have lost its way. Do this:
- 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. - Examining the contents of the xcdatamodel/d files in Finder: 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.
I was in same situation, and finally fixed.
In my case, problem come from Xcode project group property: path.
Check path property of your project group that has xcdatamodeld file.
In my situation, it was different from xcdatamodeld file really exists,
and path of xcdatamodeld file was ../Model/XX.xcdatamodeld (example)
Anyway there were no problem, but someday I removed directory that is group's path property.
So Xcode couldn't find xcdatamodeld file. I add new xcdatamodled file, but this situation repeated.
Check if your xcdatamodeld file really exists in your project setting.
The solution for me was to revert back to a working copy of my .xcdatamodeld. Then, instead of renaming it via finder or the navigator pane of XCode 4, I selected the .xcdatamodeld file in the left navigation pane and edited the .xcdatamodeld's group name in the right pane of XCode 4 under the identity heading at the top.
Once I changed the name there to match my new project name, XCode automatically updated the name of the file on the file system for me.
I did not have to edit the path property as moon6pence suggested.
精彩评论