I currently have an application that uses Core Data with Apple's NSPersistentCloudKitContainer
and I've a 2 users mentioning they lost their data when updating the app - I'm using Lightweight migrations, and the only factor they have in common is: both had no iCloud Storage left.
After further inspection I've noticed that if I go to Settings > iCloud > Disable it for my app, whenever I open my app again all my data will be gone.
As anyone run into this issue? Is this expected? Any way around it?
For reference, here's my setup code:
self.container = NSPersistentCloudKitContainer(name: "DATABASE_NAME")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
Crashlytics.crashlytics().record(error: error)
}
self.container.viewContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
self.container.viewContext.automaticallyMergesChangesFromParent = true
})