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?
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.
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.