Sanjiv Jivan
Sanjiv Jivan

Reputation: 1954

Xcode Data Model Editor not appearing

I'm using Xcode 4.2 and I'm trying to use Core Data. Upon clicking the .xcdatamodeld file I see a strange view instead of the Data Model Editor View.

Data Model Editor

I have reinstalled Xcode 4.2 and have even created a starter project from scratch with Core Data Enabled but the issue persists. When I create a Data Model using new file --> Data Model. It is not being recognized as a DataModel. Ctrl+Click --> 'Open As' only displays a "Preview" option. I compared my basic project with that created on a different machine (where everything works fine). A directory diff reveals :

  1. The Foos.xcdatamodeld file was placed under the "Copy Bundle Resources" section of the project's Build Phase instead of being under the "Compile Sources" section. I moved this file to the "Compile Sources" section but the data model editor still doesn't display.

  2. The Foos/Foos.xcdatamodeld/.xccurrentversion file in the working project looked like


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   <key>_XCCurrentVersionName</key>
   <string>Foos.xcdatamodel</string>
</dict>
</plist>

while in the non-functional one it was


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>
  1. The only other difference I noticed was that the working version had the following in the project.pbxproj file

/* Begin XCVersionGroup section */
      831B12C114A7F73600524A33 /* Foos.xcdatamodeld */ = {
         isa = XCVersionGroup;
         children = (
            831B12C214A7F73600524A33 /* Foos.xcdatamodel */,
         );
         currentVersion = 831B12C214A7F73600524A33 /* Foos.xcdatamodel */;
         path = Foos.xcdatamodeld;
         sourceTree = "";
         versionGroupType = wrapper.xcdatamodel;
      };
/* End XCVersionGroup section */

while the broken one did not have this entry.

I did a directory compare of /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates on my two machines and the templates are identical.

So I'm wondering what part of Xcode is causing the above differences on my primary dev machine. Any suggestions on things to try or what might be causing this issue?

Upvotes: 10

Views: 6862

Answers (5)

Bretsko
Bretsko

Reputation: 918

I solved the problem by opening the package contents of xcdatamodeld, dragging out the file inside with the same name and using it instead, thanks to this answer.

Upvotes: 0

Phil Hudson
Phil Hudson

Reputation: 3901

When creating a new data model, go to Editor > Add Model Version

That fixed it for me! :)

Upvotes: 0

tsuyoski
tsuyoski

Reputation: 644

I had the same problem, but by creating another user account on my Mac, I was able to create a project with Core Data where the editor opens normally. It appeared my user profile was corrupt and it couldn't be resolved by reinstalling Xcode.

Upvotes: 0

Sid Steward
Sid Steward

Reputation: 2834

I also ran into this.

I was finally able to get xcode 4.6.3 to restore the interactive editor by opening the .xcdatamodeld in my project and changing the File Type (in the file inspector) from Versioned Core Data Model to Core Data Model. I was able to change it back to Versioned Core Data Model, later, and things kept working.

Upvotes: 1

Adam Ritenauer
Adam Ritenauer

Reputation: 3181

I ran into a similar issue. The problem was the projects directory structure and how it was configured in XCode.

More details here: XCode Cant' Edit CoreData Model

Upvotes: 6

Related Questions