Migration from SwiftData/CloudKit #218
Replies: 2 comments 1 reply
-
Hi @frazzeli, some comments below:
Do you know if this behavior is documented anywhere? And does this happen when a full sign out happens from iCloud, or just when the account is "temporarily unavailable" and the user just needs to enter their password again (usually from an automated prompt by iOS).
It's correct that we use
However, And if there is a legitimate reason to keep data around even after a user signs out, we could explore possibly making that customizable in the library.
I'm sorry but I don't really have a good answer for this. Swapping out SwiftData for SQLiteData is going to be incredibly difficult, and doubly so if you have CloudKit sync turned out. At the very least I imagine you will want to release a kill switch in your app as soon as possible so that at some future date you can force all users to update to the newest version of the app. And then that new version of the app will have converted all SwiftData patterns and tools into SQLiteData patterns, and have a one-time migration that loads all of the SwiftData data into memory and imports it into the new SQLite tables. If you do all of that work before creating the That's the basic idea, but it's a lot of work and a lot of things can go wrong along the way. |
Beta Was this translation helpful? Give feedback.
-
Thanks @mbrandonw.
Not officially, but you can find other reports of it here: https://crunchybagel.com/nspersistentcloudkitcontainer/#:~:text=Changing%20iCloud%20Account
With Apple's first-party data (photos, notes, etc), I believe users are given the option to keep or delete local data when they sign out of iCloud. I think it would be a legitimate use case to allow this in third-party apps, as well, especially given that this can happen when the user hasn't intentionally signed out of their device (or may never have signed in to begin with). Making this customizable so we can notify the user before data is deleted would be a huge benefit to the user, IMO. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all, I have an app that uses SwiftData and private CloudKit sync to persist user data. NSPersistentCloudKitContainer has proven far too eager to remove the local SwiftData records for privacy reasons whenever it determines the user's iCloud account is unavailable. We haven't found a way to avoid this behavior in a fully-SwiftUI app (existing workarounds for changing the cloudkit container config on the fly seem to require UIKit), so we're looking for alternatives to SwiftData that would still let us use private CloudKit sync.
Can I get your thoughts on a couple of basic questions so I can test my assumptions?
• First is that, because SQLiteData uses CKSyncEngine instead of NSPersistentCloudKitContainer (correct?), we won't see this "privacy" behavior where local data is automatically removed when the OS reports the user has logged out of their iCloud account. Do you think that's correct?
• And second, what would the CloudKit schema production deployment process look like when switching our app from SwiftData/CloudKit to SQLiteData/CloudKit? I assume we'd need to deploy the new GRDB schema, but would that break the existing CloudKit sync for existing users who haven't yet updated their apps?
Beta Was this translation helpful? Give feedback.
All reactions