My scenario
- I have an app which stores data using SwiftData / CloudKit automatic sync
- It works as expected on iOS, sync happens even when the app is closed.
- On Mac, when mac app is closed the data from the CloudKit is not pulled into the DB.
- It would be nice if the widget on the Mac is updated even when the Mac app is closed. Like from a sync from an iPhone.
My problem:
- I don't do anything for sync other than just initializing the ModelContainer and everything is taken care of.
- The local store has its own system level tables to maintain the sync states. So I am a bit hesitant to do a separate sync in the background process (LoginItem / LaunchAgent / LaunchDaemon.
- I need to read a lot on this because I am just beginning to explore this part
Questions
- Is it feasible / advisable to have one instance of the ModelContainer created in the background process and access it in the main app for the Mac?
- Reason for asking is because ModelContainer is the one that does all the sync magically.
- Or is this too much of an overhead and users can open the app to keep the widget updated?