views:

105

answers:

2

The Xcode 4 preview is still very buggy when dealing with core data models and it has corrupted the diagram representing my model. The model itself still seems fine, but does anyone know a way of getting Xcode (3.2 or 4) to re-generate the diagram layout?

+1  A: 

I don't know of any way to rebuild the files.

The diagrams don't exist as separate files but are generated from the model files themselves on the fly. If the diagram is garbled then it is likely that the model file itself is corrupted. If it appears to work in code it might just be a previous version of the compiled mom file still in the built product.

You can poke around in the data model files. The xcdatamodel "files" are really bundles. If you remove the xcdatamodel extension from the name, they revert to ordinary folders. If versioned, you will find another xcdatamodel inside. Rename that one as well. Inside that folder, you will find two files called elements and layout. Rename them to elements.plist and layout.plist and you can open them as human readable plist files. However, I doubt they will provide much info but sometimes you can find and fix the corruption if it is obvious e.g. malformed xml.

TechZen
Yeah, I cracked open the xcdatamodel package and found the elements and layout. Converting them to plists is an interesting option.The model is definitely fine. All the model elements show up in the browser and properties panes, but the diagram just doesn't reflect the contents of the model.No matter. Clearly the guys at Apple have some work to do on the modelling tools in Xcode 4 before release. I've switched back to 3.2 for the time being and rebuilt the model. I'm just surprised that there isn't a built-in rebuild mechanism to get the diagram back in sync.
DougC
Make sure you file a bug report on it. That's why they release these betas.
TechZen
+1  A: 

I ran into a similar situation where my .xcdatamodel file displayed elements that didn't exist and arrows emerging from nowhere.

I resolved it by moving the layout file entirely from the .xcdatamodel package and then reopening the project in Xcode (v3.2.3). The diagram layout was lost (no big deal), but only the appropriate entities appear in the graph. Once I saved the .xcdatamodel file, the new layout was replaced in the package.

Thanks for the tip. For the moment I've given up on XCode 4 Preview 2 as it doesn't seem quite ready for prime-time yet, but if I do run across the situation again I'll try this approach.
DougC