cloudkit

Synchronize iOS/macOS app data across devices with CloudKit and CKSyncEngine.

Updated May 10, 2026
One-click install
npx skills add https://github.com/FelixRauch/medat-figuren --skill cloudkit-felixrauch
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cloudkit
Source: https://github.com/FelixRauch/medat-figuren/tree/main/.agents/skills/cloudkit
Command: npx skills add https://github.com/FelixRauch/medat-figuren --skill cloudkit-felixrauch

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

CloudKit integration eliminates the frustration of keeping user data consistent across iOS/macOS devices by providing a practical blueprint for record sync, subscriptions, and conflict-safe updates.

Core Features & Use Cases

  • CloudKit data synchronization: Configure CKContainer and select the right database (public/private/shared) for user-specific versus shared content.
  • Full record lifecycle with queries: Create, fetch, update, and delete CKRecord data using CKQuery and NSPredicate filtering.
  • Push-based change propagation: Use CKSubscription and/or CKSyncEngine to receive and process server-side changes efficiently.
  • SwiftData + CloudKit syncing: Implement model configuration with a CloudKit database, following CloudKit model constraints (optionals, no unique constraints, optional relationships).
  • Robust error handling and conflict resolution: Handle CKError codes (network failures, rate limiting, quota issues, token expiration) and perform three-way merges for .serverRecordChanged.
  • Optional iCloud storage options: Sync small settings via NSUbiquitousKeyValueStore and larger documents via iCloud Drive file coordination.

Quick Start

Set up CloudKit in your app, then implement a CKSyncEngine-based SyncManager that checks account status, persists sync state, processes fetched changes, and handles CKError (especially .serverRecordChanged) with three-way merge into the server record.

Frequently Asked Questions about cloudkit

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

FAQPage Schema
How do I handle CloudKit sync conflicts when CKError.serverRecordChanged is thrown?

Implement CloudKit conflict resolution by performing a three-way merge when CKError.serverRecordChanged occurs, comparing local, server, and base record states to safely update the server record without overwriting remote changes.

What's the best way to sync SwiftData with CloudKit across devices?

Sync SwiftData with CloudKit by configuring your model with a CloudKit database and following constraints like optional attributes, no unique constraints, and optional relationships, then using CKSyncEngine for incremental syncing to keep data consistent.

How does CKSyncEngine incremental syncing work for iOS apps?

CKSyncEngine incremental syncing works by persisting sync state or change tokens to track fetched changes, processing server-side updates efficiently by only retrieving modified records rather than downloading the entire database.

Does CloudKit syncing require specific handling for network and quota errors?

Yes, CloudKit syncing requires comprehensive error handling for CKError codes. You must detect and respond to network failures, rate limiting, quota issues, authentication errors, and token-expired scenarios to maintain reliable cross-device synchronization.

When should I use iCloud key-value storage versus CloudKit databases?

Use iCloud key-value storage (NSUbiquitousKeyValueStore) for small settings and iCloud Drive file coordination for larger documents, while using CloudKit databases (public, private, or shared) for structured record-based data synchronization.

How do I set up CKSubscription push updates for CloudKit data changes?

Set up CKSubscription push updates by configuring CKContainer, selecting the right database, and subscribing to record zone changes, combining subscriptions with CKSyncEngine to receive and process server-side changes automatically across devices.