Code build but I get fatal error on launch while loading the Core data
lazy var persistentContainer: NSPersistentContainer = {
/*
The persistent container for the application. This implementation
creates and returns a container, having loaded the store for the
application to it. This property is optional since there are legitimate
error conditions that could cause the creation of the store to fail.
*/
let container = NSPersistentContainer(name: "GridModel")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
return container
}()
The error message in the output window is:
myApp[8117:177239] [error] error: -addPersistentStoreWithType:SQLite configuration:(null) URL:file:///Users/xyz/Library/Developer/CoreSimulator/Devices/B58967C7-E8BA-4ED9-826A-1AB52B6C1EAC/data/Containers/Data/Application/94CFF817-B0C6-4BF4-8979-382E7C74485F/Library/Application%20Support/GridModel.sqlite options:{
NSInferMappingModelAutomaticallyOption = 1;
NSMigratePersistentStoresAutomaticallyOption = 1;
} ... returned error Error Domain=NSCocoaErrorDomain Code=134140 "(null)" UserInfo={sourceModel=(<NSManagedObjectModel: 0x60000028e740>) isEditable 1, entities {..... lists all the entities with long list of errors here.. }
I think I accidentally clicked on Xcode menu -> Editor -> Add Model Version.
Looks like some error in the Model. I am not sure if this caused the error and I dont understand how and why?'
Can someone please advise?