ggruen / CloudKitSyncMonitor

Monitor current state of NSPersistentCloudKitContainer sync
MIT License
465 stars 43 forks source link

Working with SwiftData? #27

Closed FPST-08 closed 1 month ago

FPST-08 commented 1 month ago

Before I try to implement this package into my project: Does it work for SwiftData too? When using SwiftData and its automatic syncing capability, I don't with CKContainers for example. Will the package still work as if I was using CoreData? Under the hood SwiftData is still CoreData.

ggruen commented 1 month ago

Hi @FPST-08 ,

This package is specifically designed to work with NSPersistentCloudKitContainer and merely translates notifications sent by it into states that can easily be displayed by SwiftUI. It doesn't (intentionally) interact with CoreData or CKContainer (although I do notice an import CoreData in SyncMonitor now that I look again).

I haven't used SwiftData, so I don't know about whether it's an option to use with NSPersistentCloudKitContainer or not. If so, it's possible CloudKitSyncMonitor will work with NSPersistentCloudKitContainer/SwiftData, but you'll probably be in uncharted territory.

For what it's worth, the code that listens to NSPersistentCloudKitContainer is set up in SyncMonitor at line 427.

Grant

FPST-08 commented 1 month ago

Hi @ggruen ,

I've tried your Package in combination with SwiftData and it works exactly like it is supposed to be. Thank you for your awesome package. It is exactly what I was looking for.

ggruen commented 1 month ago

Hi @FPST-08 ,

Ah, that's great to hear, and thanks for confirming that it works as others will likely have the same question.

Grant