iosxcodecore-datacore-data-migration

How to squash core data migrations?


I have an app for which I generate a seed core data database in a Mac command line program with Xcode. During beta-testing I used several model versions. Now, for the first release of the app, I want to squash the versions into one model with version 1. Is that even possible?

I removed the old model versions from the xcdatamodeld folder and set the current version to the initial one. I removed both references to the old model versions from the pbxproj file. Regardless of what I try, I get a "Persistent store migration failed, missing mapping model."-error. I tried everything listed here, namely:

Nothing helped. I am wondering from where Xcode could know about the old model... For clarification, this is referring to the database creation tool I run as a command line app on the mac, not the iOS app itself.

Other ways to squash the db are well appreciated. One alternative I am considering is renaming the database and ignoring the old one from now on.


Solution

  • Since I could not figure out how XCode knows about the old model, I went with creating the model again with a different name and adapting the urls in code. This works without a problem.

    EDIT: I finally figured it out - my self-built command line app was properly installed and thus had its own directory under ~/Library/Application Support/<name of your app>/ where its three *.sqlite files were residing. Deleting them finally got rid of the "missing mapping model" error.