Multi-platform CoreData synchronisation: deleting data from all devices except one?

I'm currently developing a multi-platform app where a standalone Watch app collects data, summarises it, then stores the summary in CoreData. The summary gets synchronised across all devices by CloudKit. However, the raw data (e.g. RR interval data from a Polar H10 heart rate monitor) are important from an historical perspective: forming the basis of further analysis, perhaps via AI. Given the limited storage, battery and processing resources on the Watch, it would be inappropriate to persistently store, or perform complex analysis of, the raw data on the Watch.

My preferred solution would be to transfer the raw data to a Mac and, once successfully received, delete it from the Watch (also from CloudKit?). The Mac would then perform further analysis and propagate an additional summary to all other devices. The problem I foresee is that, if using CoreData/CloudKit synchronisation, deleting from the Watch would delete from all other devices. With my currently limited understanding of such synchronisation, I don't see a way of not then automatically deleting the Mac's CoreData records.

Perhaps the solution is to have a separate CoreData container on the watch for the raw data, a separate CloudKit raw data container, and a separate Mac raw data container - then perform the deletes upon receipt of CloudKit update notifications (i.e. not via automatic syncs). The raw data are immutable, so there's no need to deal with updates.

I'd appreciate advice/suggestions on a workable solution.

Regards, Michaela

This seems to be the way https://developer.apple.com/documentation/coredata/linking_data_between_two_core_data_stores, at least in the first part of the problem ( separate stores). I haven’t done the watch part yet because I’ve been importing historical records into the Mac’s raw data container from an old iOS app to make sure the historical concepts are feasible.

I’m thinking of keeping raw data on the watch for a couple of weeks before deletion, but will send each session (as a batch) to CloudKit, then the Mac, after session completion.

Cheers, Michaela

Multi-platform CoreData synchronisation: deleting data from all devices except one?
 
 
Q