Master Data - Failed to load optimized model along path

I get some of these fingerprints in my console when I launch my application from Xcode 6 on my iPhone 6 with iOS 9 beta 5:

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

I can not find something related to this, can anyone understand this message?

+57
ios objective-c xcode ios9 core-data
Aug 26 '15 at 18:19
source share
4 answers

I ran into this problem and ruined a bit.

I built with Xcode 6.4, and it looks like previously the main data only generated the .mom file in the MyApp.ipa momd directory. This screenshot is taken from a project that saw several versions of Xcode.

Please note that all older versions of the model only have a .mom file. I just created a new version of the model today, and it has both a .mom and a .omo file.

enter image description here

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

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 application with the latest version of the Xcode application (7.0.1), I do not receive this warning. I assume the reason for Mahesh's solution is that re-writing the entire schema creates the .omo file that the application is looking for in the application bundle.

The solution for me was to generate a new version of the data model in the master data, and then build using Xcode 7. It seems that creating a new version of the model creates an optimized model file. In my testing, although even with this file created by Xcode 6.4, an error still throws. It was not until I tried it with Xcode 7.0.1 that the warning disappeared.

This is an assumption, but I think that if you have an existing project and you have not created a new version of the data model and have not created with Xcode 7 that the .omo file is missing, it throws a warning because it cannot find the file. However, if you checked the version of your data model and created with Xcode 6.4, it seems that an earlier version of Xcode does not do something right with the optimized version, and it does not load it, even if it is. These are just my observations.

I checked that I had an optimized model (.omo file) for downloading 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 see. Click) in the application bundle in the folder and select "Show package contents". 5. click on the .momd directory, you will see all available models of managed objects.

If all you have are .mom files and .omo files, then the warning makes sense, the application cannot open a file that does not exist.

In my testing, it seems that the warning was only informative. Because of this, I never came across this. It looks like the kernel data might try to load the optimized model first, and if that doesn't work, go back to the regular .momd model. This is just my guess.

I'm not sure that everything here is completely correct, this is what I have observed so far, trying to debug this. If anyone else can contribute more information, I welcome your input.

+7
Oct. 16 '15 at 19:16
source share

I found a solution for this. I rewrote the whole scheme, and when I run the code, I got rid of these warnings from the main data.

I suggest you back up before you try this.

Hope this helps you.

+4
Oct 15 '15 at 13:58
source share

I ran into this problem this morning. Made a small hack to make it work. I think this has something to do with version mismatch, but I'm not sure.

Anyway, if you upload momd, just add "/►filename.BIZ.mom" to NSURL to make it work.

In my case, I downloaded the Countly.momd file and ended up doing this:

 // Original loading NSURL modelURL = [[NSBundle bundleForClass:[CountlyDB class]] URLForResource:@"Countly" withExtension:@"momd"]; // Small hack modelURL = [modelURL URLByAppendingPathComponent:@"Countly.mom"]; 

Update: I used the POD that used CoreData. Removing a module and adding a source, etc. The repo immediately made the problem go away.

So this could be a problem.

+2
Sep 24 '15 at 21:21
source share

I want to answer the people who came across this when I wrote my own block, which has its own CoreData models. You probably put the model definition in the package (this is good), but you are looking for the momd file in the wrong bundle.

Say you defined your package in podspec as follows:

 'MYPodBundle' => [ 'Model/*.{xcdatamodeld,xcdatamodel}' ] 

Then you must first find this kit, and then find your model inside it .

 NSURL *bundleURL = [[NSBundle bundleForClass:[MYEntity class]] URLForResource:@"MYPodBundle" withExtension:@"bundle"]; NSBundle *bundle = [NSBundle bundleWithURL:bundleURL]; NSString *modelPath = [bundle pathForResource:@"MYCoreDataModel" ofType:@"momd"]; NSManagedObjectModel *managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:[NSURL fileURLWithPath:modelPath]]; 

So you can continue creating the CoreData stack.

// It might be a little offtopic because you are not writing your own module, but your answer is on google top.

0
Aug 10 '16 at 7:38
source share



All Articles