I really enjoyed using SwiftData for persistence until I found out that the CloudKit integration ensures changes are only eventually consistent, and that changes can propagate to other devices after as long as minutes, making it useless for any feature that involves handoff between devices. Devastating news but I guess it’s on me for nrtfm. I may try my hand at a custom model context DataStore integrating Powersync, but that’s a whole trip and before I embark on it I was wondering if anyone had suggestions for resolving this problem in a simple and elegant manager that allows me to keep as much of the machinery within Apple’s ecosystem as possible, while ensure reliable “live” updates to SwiftData stores on all eligible devices.
I don't have a lot to say about implementing a real-time data persistence system cross devices, but just to confirm that CloudKit isn't a real-time system, and so SwiftData / Core Data + CloudKit integration is not real time either, as you have found out. To optimize the overall experience, CloudKit even implemented a mechanism to throttle requests, if the rate is too high, as discussed in TN3162: Understanding CloudKit throttles.
And yes, a custom data store will be the way to go, if you would use SwiftData. You need to take care the real-time synchronization part when going along this path. There is no system-provided framework specifically for that purpose.
Best,
——
Ziqiao Chen
Worldwide Developer Relations.