David van Dugteren
David van Dugteren

Reputation: 4109

How to clear and reset Core Data data models

I have now >45 different versions of xcdatamodel in Xcode, of which 44 of them are no longer required, as I've eseentially gone for the drop/create approach of the entire database. How can I clear these out, without Xcode kicking up a fuss?

See the linked image:

https://www.dropbox.com/s/1bpdhf9bax6iicb/Screenshot%202014-05-23%2013.24.45.png

Upvotes: 3

Views: 7919

Answers (1)

rob5408
rob5408

Reputation: 2982

Note: this approach is waaaaayyyy simpler: https://stackoverflow.com/a/6712191/84783, but if you wanna get up to your elbows with project files, try my steps below.


I think they keep these around for current installations to do model migrations. Sadly I think you have some manual project file hacking.

  • Make sure you have the model you want set as the current model
  • Close Xcode
  • Right click on "Model.xcdatamodeld" in Finder
  • Choose Show Package Contents
  • Delete the models you no longer want
  • Right click on "MyProject.xcodeproj"
  • Choose Show Package Contents
  • Open project.pbxproj in a text editor
  • Search for ".xcdatamodel" and delete entries (Model.xcdatamodel and "Model X.xcdatamodel") no longer in use
  • Careful not to delete ".xcdatamodeld" files

Hope this helps, Rob

Upvotes: 6

Related Questions