核心数据 - 无法在路径加载优化模型 [英] Core Data - Failed to load optimized model at path

查看:213
本文介绍了核心数据 - 无法在路径加载优化模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在控制台中使用iOS 9 beta 5的iPhone 6从Xcode 6运行我的应用程序时,

CoreData:无法在路径'/var/mobile/Containers/Bundle/Application/0000000B-BDBC-0000-000B-0000FB00000B/Distribution.app/database.momd/database.omo'下载优化模型


我没有找到与此相关的东西,有没有人对这个消息有一些线索?

解决方案

我遇到这个问题,并做了一些挖掘。



我一直在使用Xcode 6.4构建,它看起来像以前的核心数据只是在MyApp.ipa momd目录中生成一个.mom文件。这个截图来自一个已经看到过几个版本的Xcode的项目。



请注意,所有较旧的型号只有一个.mom文件。我今天刚刚创建了一个新的模型版本,它有一个.mom和一个.omo文件。





看起来Xcode 6.4一些beta 7.x版本也不知道如何加载数据模型的优化版本,因为我也得到

  2015-10-16 11:11:42.563 MyAppName [1767:599635] CoreData无法在路径'/ var / mobile / Containers / Bundle / Application / D887D60B-FB28-4059-8167-F573460D98F8 / MyAppName.app/MyDataModel.momd/MyDataModel3_0Analytics.omo'

在使用6.4编译时出现警告。但是,当使用最新的应用商店版本的Xcode(7.0.1)编译应用程序时,我没有得到那个警告。我猜测,Mahesh的解决方案是工作的原因是因为重写整个模式创建了应用程序在应用程序包中查找的.omo文件。



我的解决方案是在核心数据中生成一个新的数据模型版本,然后用Xcode 7构建。似乎创建一个新的模型版本创建了优化的模型文件。在我的测试虽然,即使用这个文件创建Xcode 6.4仍然抛出的错误。直到我试图与Xcode 7.0.1警告消失了。



这是推测,但我想如果你有一个现有的项目,并没有创建一个新的数据模型版本和构建与Xcode 7的.omo文件丢失,所以它抛出的警告,因为它找不到该文件。然而,如果你已经版本化数据模型和构建与Xcode 6.4似乎早期的Xcode版本不做正确的优化版本,它不加载它,即使它的存在。这些只是我的意见,虽然。



我确认我有一个优化的模型(.omo文件)加载通过执行以下操作:
1. archive your project
2.将.ipa扩展名更改为.zip
3.展开zip文件
4.单击payload文件夹,然后右键单击应用程序包并选择显示包内容。
5.点击.momd目录,您应该可以看到所有可用的受管对象模型。



如果所有的都是.mom文件,没有.omo文件,然后警告完全有意义,应用程序无法打开一个不存在的文件。



在我的测试中,似乎警告只是信息。我从来没有因为它的任何崩溃。看起来核心数据可能会尝试首先加载优化的模型,如果失败回到正常的.momd模型。这只是我的猜测,虽然。



我不知道这里的一切是否是完全正确的,这是我所观察到的迄今为止试图调试这个。如果任何人都可以提供任何更多的信息,我欢迎您的输入。


I'm getting some of these prints in my console while running my application from Xcode 6 in my iPhone 6 with iOS 9 beta 5:

CoreData: Failed to load optimized model at path '/var/mobile/Containers/Bundle/Application/0000000B-BDBC-0000-000B-0000FB00000B/Distribution.app/database.momd/database.omo'

I cound't find something related to this, does anyone have some clue about this message?

解决方案

I've run into this issue and did some digging around.

I've been building with Xcode 6.4 and it looks like previously core data only produced a .mom file in the MyApp.ipa momd directory. This screenshot is from a project that has seen several version of Xcode.

Notice all the older model versions only have a .mom file. I just created a new model version today and it has both a .mom and an .omo file.

It appears that Xcode 6.4 (and perhaps some of the beta 7.x versions as well) do not know how to load the optimized version of the data model because I also get the

2015-10-16 11:11:42.563 MyAppName[1767:599635] CoreData: Failed to load optimized model at path '/var/mobile/Containers/Bundle/Application/D887D60B-FB28-4059-8167-F573460D98F8/MyAppName.app/MyDataModel.momd/MyDataModel3_0Analytics.omo'

warning when compiling with 6.4. However, when compiling the app with the latest app store version of Xcode (7.0.1) I do not get that warning. I'm guessing that the reason Mahesh's solution is working is because re-writing the entire schema creates the .omo file the app is looking for in the app bundle.

The solution for me was to generate a new data model version in core data and then build with Xcode 7. It seems that creating a new model version creates the optimized model file. In my testing though, even with this file created Xcode 6.4 still throws the error. It wasn't till I tried it with Xcode 7.0.1 that the warning went away.

This is speculation but I think if you have an existing project and have not created a new data model version and build with Xcode 7 that the .omo file is missing, so it's throwing the warning because it cannot find the file. However if you've versioned your data model and build with Xcode 6.4 it seems that the earlier Xcode version doesn't do something correctly with the optimized version and it doesn't load it even if its there. These are just my observations though.

I verified that I had an optimized model (.omo file) to load by doing the following: 1. archive your project 2. change the .ipa extension to .zip 3. expand your zip file 4. click on the "payload" folder and right click (or cmd click) on the app bundle in the folder and select "Show Package Contents". 5. click on the .momd directory, you should see all of your available managed object models there.

If all you have is .mom files and no .omo files then the warning makes complete sense, the app is unable to open a file that does not exist.

In my testing it seems like the warning was informational only. I never had any crashing because of it. It seems like core data may try to load the optimized model first, and if that fails fall back to the regular .momd model. This is merely my speculation though.

I'm not sure if everything here is entirely correct, this is just what I've observed so far in trying to debug this. If anyone else can contribute any more info I welcome your input.

这篇关于核心数据 - 无法在路径加载优化模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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