cloudkit

Implement CloudKit and iCloud sync for iOS/macOS apps.

Updated May 6, 2026
One-click install
npx skills add https://github.com/Roy-wonji/claude-config --skill cloudkit-roy-wonji
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cloudkit
Source: https://github.com/Roy-wonji/claude-config/tree/main/skills/swift-ios-skills/skills/cloudkit
Command: npx skills add https://github.com/Roy-wonji/claude-config --skill cloudkit-roy-wonji

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you implement reliable CloudKit and iCloud sync for iOS/macOS apps, including data modeling, background syncing, and robust handling of conflicts and errors that can otherwise cause missing updates or inconsistent state across devices.

Core Features & Use Cases

  • Container & Database Setup: Configure public/private/shared CloudKit databases using CKContainer and select the correct database for the data you’re syncing, with container setup guidance.
  • Record Operations, Queries, and Subscriptions: Create and manage CKRecord CRUD flows, build CKQuery predicates, and use CKSubscription push-based updates instead of polling.
  • Production-Grade Sync & Safety: Use CKSyncEngine (iOS 17+) with persisted stateSerialization, integrate SwiftData with CloudKit, handle iCloud account status, and perform three-way conflict resolution for .serverRecordChanged using ancestor/client/server records.
  • Additional Sync Options: Support lightweight preferences syncing via NSUbiquitousKeyValueStore and document-level sync using iCloud Drive file coordination.

Quick Start

Ask the AI to generate a CloudKit sync implementation plan for your SwiftData model using a private database, including subscription or CKSyncEngine setup, conflict resolution strategy, and an error-handling checklist for common CKError codes.

Frequently Asked Questions about cloudkit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I sync SwiftData with iCloud using CloudKit?

You can sync SwiftData with iCloud by configuring ModelConfiguration with a CloudKit container. This setup enables automatic data synchronization across iOS and macOS devices using private or shared databases.

How do I handle CloudKit sync conflicts for serverRecordChanged errors?

Perform three-way merge conflict resolution targeting the `.serverRecordChanged` error by merging changes from ancestor, client, and server records into the serverRecord to safely resolve sync inconsistencies across devices.

How do I set up CKSyncEngine for incremental iCloud sync?

Configure CKSyncEngine on iOS 17+ to manage incremental iCloud sync. Persist `stateSerialization` and change tokens to maintain sync state across sessions and safely resume data synchronization after network interruptions or account changes.

What is the best way to get push-based updates from CloudKit instead of polling?

Use CKSubscription to receive push-based updates from CloudKit instead of polling. Configure subscriptions with CKQuery predicates to monitor specific record changes and trigger remote notifications when data modifications occur.

Can I use NSUbiquitousKeyValueStore for lightweight iCloud preferences sync?

Yes, use NSUbiquitousKeyValueStore for lightweight iCloud preferences sync. This approach supports syncing small amounts of user preference data or app state quickly across devices without requiring full CloudKit record operations.

Why do I need to check CKAccountStatus before syncing with iCloud?

Check CKAccountStatus before syncing to verify the user has a valid iCloud account. Prechecking account status prevents sync failures and allows your app to handle unauthenticated states or account switching gracefully before attempting data operations.