Fix Core Data Fail

2020-03-31 07:40发布

I have an app in the app store that uses Core Data and I have to release an update by tomorrow. However, I am experiencing some problems with Core Data.I by mistake made changes to my model in Core Data and now my app is crashing. I tried migrating the data but the app still crashes when I updated it on my iPhone. Is there anyway to fix it?

Thank you so much for your help!

EDIT: I am trying to add the .mom file to the app but I can not get it into the Bundle:

enter image description here

EDIT 2: Do I delete the entirely Planner.xcdatamodeld:

enter image description here

3条回答
仙女界的扛把子
2楼-- · 2020-03-31 08:22

You can recover the original Core Data model from the production app's bundle.

Use Finder to open the app bundle (Show Package Contents) and look for a .mom file or a .momd directory.

Copy the file or directory to some location outside the bundle.

Create a new XCode project with Core Data.

In XCode select the newly created projects Core Data model.

Go to the XCode Editor -> Import menu and select the .mom file you have just copied, if need be find the correct version in the .momd directory.

You should now have the model in XCode, save and copy the model file to you original project...

In XCode delete the incorrect model from your project (remember to save a copy first so you have a copy of the new changes)

Use the XCode Add File to... menu to add the old model to the original project

Now compile and run the app to confirm it opens the old file correctly

Now add a new model version and add the changes to this new version - make sure you select the new model version in XCode before making changes

enter image description here

查看更多
时光不老,我们不散
3楼-- · 2020-03-31 08:35

You should revert your model to the one that you have in App Store. Then you should Add new model version of your Core Data model. If you can't revert to that model you should try to make it exactly as it was.

After you've done a new model version, you should select that one and make the changes.

查看更多
Root(大扎)
4楼-- · 2020-03-31 08:37

If you don't use Git (which is really, really bad, by the way), you can just install your app from the App Store and use some iPhone File Manager to get the old mom file from your app. It would be in /apps/yorapp/youapp.app/ folder with .mom extension Try iExplorer, for example, it's free.

查看更多
登录 后发表回答