r/iOSProgramming • • 19d ago

Discussion Moving off swiftdata/icloud

I’ve been working on a productivity app for a couple years and recently made the decision to move away from SwiftData’s native iCloud syncing in favor of my own syncing solution. Users are prompted to migrate on their next launch after update and we leave iCloud data in place as a failsafe in case something goes wonky with migration.

For most users, iCloud syncing worked pretty well. However, some users were experiencing pretty lengthy delays when syncing between devices, particularly on older iPhones. Others were having trouble getting their data back after reinstalling the app. Unfortunately, there wasn’t a whole lot I could do to troubleshoot these issues.

Building my own solution has been an interesting challenge. Handling offline changes, resolving conflicts between devices, migrating existing user data, and making sure nothing gets lost in the process adds a bit of complexity.

One of my biggest priorities throughout this transition has been maintaining user privacy since many of my users value the fact that I can’t see their data. I’m using Apple’s CryptoKit with AES-192 encryption to protect user content. While I surface some basic metadata, such as the number of tasks or habits a user has and their associated timestamps, the actual content of those records is encrypted.

This gives me a much better ability to troubleshoot syncing issues without needing to see anyone’s personal content. And with such a small user base the cost is of my own backend infrastructure is worth it.

I’m curious if any other people here have gone through something similar. I’d love to hear about your experiences with SwiftData and iCloud syncing, particularly in production apps.

7 Upvotes

19 comments sorted by

View all comments

3

u/New_Barber8073 19d ago

One thing that might help is a way to verify a migration per user before anything is cleaned up, like a checksum or record count comparison between the old and new stores. Keeping the iCloud data as a fallback is smart, so it may also be worth deciding up front what condition finally lets you delete it.

2

u/Awkward_Departure406 19d ago

I do have analytics around what users are migrated but I think I am not gonna delete iCloud data for users ever. Since most users don’t have that much stored in iCloud (my app is mostly text content and route data) it’s a pretty insignificant impact on their storage. Plus users always have the option of manually deleting their data from my app themselves/turning off iCloud for my app. Me doing it for them is high risk, low reward I think

2

u/New_Barber8073 18d ago

That seems like a sensible tradeoff. Keeping deletion in the user’s hands avoids a risky cleanup step, especially when the storage cost is small.