core-data identifier - Xcode 4, Core Data Model Version-Set Current Version

versioning and (7)

I'm confused about how to perform the following function in Xcode 4 to set the model to use after creating a versioned model.

Design > Data Model > Set Current Version


This worked for me:

selecting the core data model version

Now my automatic db model migration works(with the automatic migration code in the delegate).

You can also use setter method from CoraData ...
Just do something like this...

In your CustomCoreDataManager.m:

#import "ObjectiveRecord.h"

and call the init method like this

- (instancetype)init {

    self = [super init];

    if (self) {           
        [[CoreDataManager sharedManager] setModelName:@"YourModelName"];

    return self;

In Xcode 4, if you only see one version of your data model under the "Versioned Core Data Model - Current" section of the file inspector when you have your *.xcdatamodeld file selected; or you have a 2nd version of your *.xcdatamodel file showing outside of the xcdatamodeld bundle in Xcode's project navigator, read below.

To fix this:

1) Remove both both the *.xcdatamodeld and *.xcdatamodel references from Xcode by right clicking on them in the project navigator and hitting "Delete".

2) When prompted by Xcode, click Remove References Only (very important).

3) Restart Xcode for good measure in case there is any caching going on.

4) Re-add the single *.xcdatamodeld file that contains both *.xcdatamodel files.

Xcode should now recognize the relationships and allow you to expand the *.xcdatamodeld file in the project navigator to show both *.xcdatamodel files under the parent xcdatamodeld bundle, also showing a green checkmark next to the current model. This should also allow you to select the current version of the data model in the file inspector instead of only showing one version.

For Xcode 4.2

  1. Click on YourModel.xcdatamodeld

  2. Make the side pane visible

  3. Under "versioned core data model", select the "current drop down box", select you data model.

Now the green tick mark is moved to your current data model.

  1. Click on the top level .xcdatamodelId file (the one that has the many versions of .xcdatamodel under it as children).
  2. Make sure the Utilities sidepane is visible (if not click on the third "View" button at the top right of the window).
  3. In the Utilities sidepane select the File inspector (little paper icon on the top left)
  4. You will see "Versioned Core Data Model" as a group so just change the "Current" drop-down to your new version.

Searching in Xcode's Help for "Current Version" yields a recipe "Setting a Managed Object Model’s Current Version" which describes how to do this...

I've just found the need to do this. I created a new model version then realised I didn't need it after all. I was surprised to find there was no way of deleting it (that I could find) from Xcode. Still, to remove it I did the following:

First I made sure it wasn't my current model version. Then I went to Finder and found my *.xcdatamodeld file. Right click and Show Package Contents on that. In there you will find the actual model file and can delete it.

This still doesn't remove it from Xcode and it will show red in the Files and Groups. To stop this from happening go back to Finder and Show Package Contents on your main *.xcodeproj file (you may want to make sure you have a backup of this first). In there open up and edit project.pbxproj do a find on your model version name, in my case "interval 8". For me it appeared on two separate lines. I removed these lines and now it's completely removed from Xcode.

core-data xcode4