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

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

问题描述

遇到问题...我有一个应用程序在应用商店,它使用核心数据...我已经更新我的模型正确(使用版本等),但只是最近我不小心失去了我的最新模型因此现在我得到这个错误:reason =无法找到源存储模型;

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!

推荐答案

您可以从应用程式的应用程式商店副本中恢复资料模型,然后将它们汇入您的专案。核心数据模型不按照源代码的方式编译,因此逆转过程通常是有效的。以下假设您已在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


$ b b

这会创建一个名为 Payload 的目录,其中包含应用程序及其包。软件包包含Core Data模型。将其复制到捆绑包中:

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

如果您在应用商店中已有多个版本,则该模型是包含多个妈妈的 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。创建数据模型的新版本,但不要使其成为最新版本。 删除此版本中的所有内容,所有实体和所有内容。在显示现在为空的模型时,转到编辑器菜单并选择导入... 。在文件打开对话框中,从上面导航到 / 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项目。

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天全站免登陆