// the find
ggruen/CloudKitSyncMonitor
Monitor current state of NSPersistentCloudKitContainer sync
A Swift package that wraps NSPersistentCloudKitContainer's notification spam into @Published properties you can actually use. Solves the real problem that CloudKit can silently stop syncing with no indication to the user or developer. iOS/macOS only, obviously.
Catches the genuinely insidious 'isNotSyncing' case where CloudKit reports the account as available but sync has quietly stalled — this is the bug that bites real users. SwiftUI integration is dead simple: drop in SyncStatusView and you're done. The state enum (notStarted/inProgress/succeeded/failed) maps cleanly onto what you'd want to show in UI. Updated to Swift 6 concurrency as of June 2025, so it won't fight you in modern codebases.
It's a single 580-line file doing everything — if Apple changes the notification names or payloads, the whole thing breaks and you're waiting on a maintainer. No mechanism to distinguish a transient network blip from a real sync failure, so you'll get false 'broken' states on flaky connections. Tests are minimal and don't cover the notification-parsing logic, which is the most fragile part. The singleton pattern (SyncMonitor.default) makes testing your own code against it annoying.