Incompatible Object Model Version

2019-02-23 12:11发布

Can anyone explain what's going on here? I have a file I JUST saved from a new version of my application - yet if i close my application and double click that document file, it gives me this error:

The document “main” could not be opened. The managed object model version used to open the persistent store is incompatible with the one that was used to create the persistent store.

Now, I have checked Google for this and it appears to be fairly common, however, I tried the advise of deleting the files in the Application Support Folder (it's folder doesn't exist for some reason) and cleaned all targets from XCode (Build > Clean All Targets) with no luck. The weirdest part is, when I accept the error and take a look at the application it loaded, it's an old version. Where can I find this mystery version of my application and how do I fix it??!

2条回答
狗以群分
2楼-- · 2019-02-23 12:34

I got around this issue by suppressing CoreData version check:

  NSDictionary *options = @{NSIgnorePersistentStoreVersioningOption:@NO}
  NSPersistentStoreCoordinator *coordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:mom];
  if (![coordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:url options:options error:&error]) {
    [[NSApplication sharedApplication] presentError:error];
    return nil;
  }
查看更多
兄弟一词,经得起流年.
3楼-- · 2019-02-23 12:55

Just for anyone who's having issues with this - I was also having issues installing the application correctly (when testing for App Store submission), and when looking at Installer Logs, it showed my app in some WEIRD locations on the computer. Delete those and reinstall (or don't, if just debugging from XCode) and problem solved.

查看更多
登录 后发表回答