I am suddenly getting a bunch of warnings on iOS12/XCode 9. Why are there multiple managedObjectModels ? The app only has one *.xcdatamodeld file but there are multiple versions within the model.
Is this some new iOS12 Coredata feature and is there something I can do to prevent this warning or should I just ignore it?
2018-09-18 11:45:34.487073+1000 xxxxxxxxx[4422:1419983] [error] warning: 'Stats' (0x2812f1550) from NSManagedObjectModel (0x2806ff480) claims 'Stats'.
CoreData: warning: 'Stats' (0x2812f1550) from NSManagedObjectModel (0x2806ff480) claims 'Stats'.
2018-09-18 11:45:34.487084+1000 xxxxxxxxx[4422:1419983] [error] warning: 'Stats' (0x2812f3bd0) from NSManagedObjectModel (0x2806b18b0) claims 'Stats'.
CoreData: warning: 'Stats' (0x2812f3bd0) from NSManagedObjectModel (0x2806b18b0) claims 'Stats'.
I just resolved the same error where I had used a computed property for my persistent container. Thus everytime the app accessing persistent container/store, new data model instance is created from the disk.
After I change persistent container to a lazy stored property, the issue's disappeared.
[update]
Currently, I use a separate class for core data stack where a singleton like below is used:
Then I may comfortably use computed property in tableViewController extension:
of course you need to call the func loadStore in AppDelegate didFinishLaunchingWithOptions block to load persistent store first where using DispatchGroup() in completionHandler to control loading first view controller's data model.