Reputation: 555
I have an iOS app written in Swift. The live version is 1.4.3 and it has version 2 of ".xcdatamodeld" as default.
Now I created its new version 1.5.0 which has 3rd version of ".xcdatamodeld" as default.
In Appdelegate:
lazy var persistentContainer: NSPersistentContainer = {
let container = NSPersistentContainer(name: "MSN_App")
let fileName="MSN_App"+".sql"
if let url=FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).last?.appendingPathComponent(fileName){
let description = NSPersistentStoreDescription(url: url)
description.shouldMigrateStoreAutomatically = true
description.shouldInferMappingModelAutomatically = true
container.persistentStoreDescriptions=[description]
Log.b("COREDATA: Sqlite File ALREADY present.")
}else{
Log.b("COREDATA: Sqlite File NOT present yet.")
}
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
return container
}()
Its crashing when user updates from 1.4.3 to 1.5.0. Crash report:
MSN_App_Release/AppDelegate.swift:518: Fatal error: Unresolved error Error Domain=NSCocoaErrorDomain Code=134110 "An error occurred during persistent store migration." UserInfo={sourceURL=file:///var/mobile/Containers/Data/Application/65182A1B-A541-485A-A5A7-BD79AFCCEB06/Library/Application%20Support/MSN_App.sql, reason=Cannot migrate store in-place: I/O error for database at /var/mobile/Containers/Data/Application/65182A1B-A541-485A-A5A7-BD79AFCCEB06/Library/Application Support/MSN_App.sql. SQLite error code:1, 'table ZEKYCINFO already exists', destinationURL=file:///var/mobile/Containers/Data/Application/65182A1B-A541-485A-A5A7-BD79AFCCEB06/Library/Application%20Support/MSN_App.sql, NSUnderlyingError=0x28174e910 {Error Domain=NSCocoaErrorDomain Code=134110 "An error occurred during persistent store migration." UserInfo={NSSQLiteErrorDomain=1, NSFilePath=/var/mobile/Containers/Data/Application/65182A1B-A541-485A-A5A7-BD79AFCCEB06/Library/Application Support/MSN_App.sql, NSUnderlyingExcep
Upvotes: 0
Views: 404
Reputation: 1
Just delete the app from your ios simulator as well as clean the build folder in xcode (go to Product > Clean build folder)
And that's it, Just run your App
Upvotes: -1