Sarmad Zaheer
Sarmad Zaheer

Reputation: 35

App Crashes on test flight after installing due to CoreData Migration

I have an older version of my app on testflight. I added 2 entities to coreData and I was not familiar with the migration requirements. Now my app crashes with the following error on the piece of code I attached

lazy var persistentContainer: NSPersistentContainer = {
    let container = NSPersistentContainer(name: "LocalDatabase")
    /*add necessary support for migration*/
        let description = NSPersistentStoreDescription()
        description.shouldMigrateStoreAutomatically = true
        description.shouldInferMappingModelAutomatically = true
        container.persistentStoreDescriptions =  [description]
        /*add necessary support for migration*/
    container.loadPersistentStores(completionHandler: { (_, error) in
        if let error = error as NSError? {
            fatalError("Unresolved error \(error), \(error.userInfo)")
        }
    })
    return container
}()

The Crash occurs at second line. The app isn't live yet, so it is a possibility for me to make sure that I perform the migration next time I make a change to core Data. But is there something I can do now to resolve this issue.

I don't get an explicit error when I try to build directly on device. It just gives the unable to install error Crash logs

Upvotes: 0

Views: 64

Answers (0)

Related Questions