Xcode 4, Core Data Model Version - Set Current Version

29,955

Solution 1

  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.

Solution 2

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.

Solution 3

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.

Solution 4

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

Solution 5

Important note to the previous answers: One one the entities in the model needs to be focused in order for the dropdown menu to appear.

Steps for Xcode 12.1

  1. Select the topmost data model (the one that has children version models). enter image description here
  2. Select one of the entities for the dropdown to appear. enter image description here
  3. Select model version from the dropdown menu enter image description here
Share:
29,955

Related videos on Youtube

Nate Potter
Author by

Nate Potter

I have 10 years iOS development experience designing, building and enhancing mobile applications in Swift, Objective-C and C#. I’m comfortable leading in an agile sprint-driven iterative environment, integrating new features into large and complex code bases. Familiar with Test Driven Development and design patterns such as MVC, MVVM, VIPER, MVP and CleanSwift(VIP). Passionate about sustainable code and building products that enhance society.

Updated on October 19, 2020

Comments

  • Nate Potter
    Nate Potter over 3 years

    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

    • erik
      erik over 12 years
      I wish I could vote this up every time I have to re-reference it.
  • Nate Potter
    Nate Potter about 13 years
    Awesome, thanks! Also found that same pane under View > Utilities > File Inspector
  • Chris
    Chris almost 13 years
    still getting used to the changes between Xcode 3 and 4, thanks!
  • bshirley
    bshirley almost 13 years
  • StuFF mc
    StuFF mc about 12 years
    There's nothing like "versioned core data model" in the "Object Library". The first answer (from Mac_Cain13) is correct, although I seem to have a weird bug with my model being outside of the .modeld in Xcode.
  • Andrew
    Andrew about 12 years
    @StuFFmc - Check my post below to fix the issue of the xcdatamodel file being outside of the xcdatamodeld bundle in Xcode's project navigator.
  • Steve Madsen
    Steve Madsen about 12 years
    And thus endeth the head scratching.
  • morph85
    morph85 over 8 years
    I accidentally changed the parent xcdatamodelid to application bundle and this solution helped!