Heres the problem... I Have an app in the app store, which uses core data... I have been updating my model correctly (using versions etc) but Just recently I have accidental
You can recover the data model from an app store copy of your app, and import that back into your project. Core Data models don't get compiled in the same way that source code does, so reversing the process is usually effective. The following assumes that you have downloaded the current app store version of the app in iTunes on your Mac:
First copy the app store bundle to a safe place:
cp ~/Music/iTunes/Mobile\ Applications/YOUR-APP-NAME.ipa /tmp
cd /tmp/
Next open up that package, which is really just a zip file.
unzip YOUR-APP-NAME.ipa
This creates a directory called Payload
that contains the app and its bundle. The bundle contains the Core Data model. Copy that out of the bundle:
cp -rp Payload/YOUR-APP-NAME.app/YOUR-MODEL-NAME.momd /tmp/
(adjust the name to match your data model).
If you already have more than one version in the app store, the model is a momd
that contains multiple mom
files. Each mom
file corresponds to a model version. One of them is the one you need. You'll need to figure out which is which.
Now, switch to Xcode. Create a new version of the data model but don't make it current. Delete everything in this version, all entities, everything. With the now-empty model displayed, go to the Editor
menu and select Import...
. In the file open dialog, navigate to the copy of your data model in /tmp/
from above. Select the version you need to recover and click "Open".
All of the entities from that version of the model are now present in the new model file you just created. You can now use this model as the "original" model when doing model migration.
Alternatively, instead of importing into Xcode, you can use my momdec project to decompile the model in place. That will produce an uncompiled Core Data model that you could add to your Xcode project.
If the model is unrecoverable, you can "fake it".
For anyone showing up on this question who is not trying to migrate a core data model to another this error can also show up if you are trying to save data to core data that has some values in your entity not being set. Make sure all your data variables are being set and set correctly to avoid this error that dreams of MacBook Pros riding unicorns may live forever in your reality!