核心数据“找不到源存储模型"; [英] core data "Can't find model for source store";

查看:18
本文介绍了核心数据“找不到源存储模型";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题来了...我在应用商店中有一个应用程序,它使用核心数据...我一直在正确更新我的模型(使用版本等)但最近我不小心丢失了我的最新模型(那个对应于应用商店),所以现在我收到这个错误:reason = "Can't find model for source store";

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 accidentally lost my latest model (the one that corresponds with the app store) and so now I get this error: reason = "Can't find model for source store";

我已经创建了我的模型,据我所知,我所做的更改与以前的版本完全相同……但我仍然无法让它喜欢我的模型版本.所以我的问题是,我能否以某种方式欺骗核心数据,使其认为它具有正确的版本?或者有什么方法可以检查哪些实体有问题?我知道核心数据存储模型的散列以检查版本是否相同,但我不知道版本模型在多大程度上必须相同才能使散列检查"成功..

I have created my model and to the best of my knowledge I have made the changes exactly the same from the previous version... yet I still can't get it to like my model version. So my question is, can I somehow trick core data to thinking it has the right version? or is there a way I can check which entities its having trouble with? I understand that core data stores a hash of the model to check that the versions are the same, but I don't know the extent to which the version models have to be the same in order for the 'hash check' to be successful..

任何帮助都会很棒!谢谢!

Any help would be great! Thanks!

推荐答案

您可以从应用的应用商店副本中恢复数据模型,然后将其重新导入到您的项目中.Core Data 模型的编译方式与源代码不同,因此逆向该过程通常是有效的.以下假设您已在 Mac 上的 iTunes 中下载了该应用的当前应用商店版本:

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/

接下来打开那个包,它实际上只是一个 zip 文件.

Next open up that package, which is really just a zip file.

unzip YOUR-APP-NAME.ipa

这会创建一个名为 Payload 的目录,其中包含应用程序及其包.该包包含核心数据模型.从包中复制它:

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

如果您在应用商店中已有多个版本,则模型是一个包含多个 mom 文件的 momd.每个 mom 文件对应一个模型版本.其中之一就是您需要的.你需要弄清楚哪个是哪个.

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.

现在,切换到 Xcode.创建数据模型的新版本,但不要使其成为最新版本.删除此版本中的所有内容、所有实体、所有内容. 显示现在为空的模型后,转到 Editor 菜单并选择 Import....在文件打开对话框中,从上方导航到 /tmp/ 中的数据模型副本.选择您需要恢复的版本,然后点击打开".

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.

或者,您可以使用我的 momdec 项目来反编译模型,而不是导入到 Xcode.这将生成一个未编译的 Core Data 模型,您可以将其添加到您的 Xcode 项目中.

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.

这篇关于核心数据“找不到源存储模型";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆