
Cloudkit
Implement, review, or improve CloudKit and iCloud sync in iOS/macOS apps.
Install
npx skills add dpearson2699/swift-ios-skills --skill cloudkit -g -a claude-code -y- Repository
- dpearson2699/swift-ios-skills1.3k
- Category
- Mobile
- Updated
- 3mo ago
- License
- See repository
- Context cost
- Mediumabout 3,000 tokens
- Runs scripts
- No, instructions only
What it does
Implement, review, or improve CloudKit and iCloud sync in iOS/macOS apps. Use when working with CKContainer, CKRecord, CKQuery, CKSubscription, CKSyncEngine, CKShare, NSUbiquitousKeyValueStore, or iCloud Drive file coordination; when syncing SwiftData models via ModelConfiguration with cloudKitDatabase; when handling CKError codes for conflict resolution, network failures, or quota limits; or when checking iCloud account status before performing sync operations.
CloudKit
Sync data across devices using CloudKit, iCloud key-value storage, and iCloud Drive. Covers container setup, record CRUD, queries, subscriptions, CKSyncEngine, SwiftData integration, conflict resolution, and error handling.
Contents
- Container and Database Setup
- Workflow
- CKRecord CRUD
- CKQuery
- CKSubscription
- CKSyncEngine (iOS 17+)
- SwiftData + CloudKit
- NSUbiquitousKeyValueStore
- iCloud Drive File Sync
- Account Status and Error Handling
- Conflict Resolution
- Common Mistakes
- Review Checklist
- References
Workflow
- Choose the database scope and sync owner; verify capability, container, account status, schema, and environment before writing records.
- Make a local change durable, enqueue it, then let subscriptions or
CKSyncEnginedrive remote work rather than polling. - Persist change tokens or sync-engine state after successful application.
- Test offline edits, partial failure, rate limiting, token expiry, conflict, account loss, zone deletion, and relaunch.
- On failure, classify the
CKError, restore the affected fixture or queue item, apply the documented retry/reset/merge action, and rerun the same scenario. Never restart a full sync blindly after partial success.
Load references/cloudkit-patterns.md for incremental zone changes, shares, assets, batch operations, and Dashboard procedures.
Container and Database Setup
Enable iCloud + CloudKit in Signing & Capabilities. A container provides three databases:
