CloudKit Setup for SQLiteData
Complete setup guide for CloudKit sync with SQLiteData — from Xcode capabilities through production deployment.
SQLiteData context: These are the infrastructure steps needed before writing any SyncEngine code. After completing setup here, configure SyncEngine per /skill sqd-cloudkit.
Step 1: Enable iCloud Capability
- Add capability: follow Apple's "Adding capabilities to your app" guide
- Select iCloud from Xcode's Capabilities library
- In the Services section, check CloudKit
- Xcode adds these entitlements automatically:
com.apple.developer.icloud-services
- Push Notifications capability (CloudKit uses push to notify of server changes)
Removing the iCloud capability in Xcode does not auto-disable it in your developer account — you must do that manually.
iCloud Services Overview
| Service |
Use Case |
Storage |
| Key-value storage |
Small data (preferences), up to 1 MB / 1024 pairs |
NSUbiquitousKeyValueStore |
| iCloud Documents |
File-based sync via UIDocument/NSDocument |
Ubiquity container (on-disk) |
| CloudKit |
Structured data with full schema control + sharing |
CKContainer databases |
For SQLiteData apps, enable CloudKit.
Managing Containers
After adding iCloud capability, Xcode fetches existing containers from your developer account.
To create a new container:
- Click Add (+) below the containers list
- Enter name: must start with
iCloud. and use reverse DNS (e.g., iCloud.com.example.myapp)
- Click OK
For SQLiteData, pass it to SyncEngine:
$0.defaultSyncEngine = try SyncEngine(
for: $0.defaultDatabase,
tables: ...,
containerIdentifier: "iCloud.com.example.myapp" // nil = auto from entitlements
)
Step 2: Enable Remote Notifications Background Mode
- Select your project in Xcode's Project navigator
- Select the app target → Signing & Capabilities
- Add Background Modes capability (if not present)
- Check Remote notifications
This allows CloudKit to silently notify your app of server-side changes, which SyncEngine uses to trigger incremental sync.
Use sparingly — overuse impacts battery life and device performance.
All Background Modes Reference
| Mode |
Info.plist Value |
Platforms |
| Audio, AirPlay, PiP |
audio |
iOS, iPadOS, tvOS, visionOS |
| Location updates |
location |
iOS, iPadOS, watchOS |
| Voice over IP |
voip |
iOS, iPadOS, visionOS, watchOS |
| External accessory |
external-accessory |
iOS, iPadOS |
| Bluetooth LE central |
bluetooth-central |
iOS, iPadOS, visionOS |
| Bluetooth LE peripheral |
bluetooth-peripheral |
iOS, iPadOS |
| Background fetch |
fetch |
iOS, iPadOS, tvOS, visionOS |
| Remote notifications |
remote-notification |
iOS, iPadOS, tvOS, visionOS, watchOS |
| Background processing |
processing |
iOS, iPadOS, tvOS, visionOS |
Step 3: Deploy Schema to Production
During development, you create your schema and test in the development environment. Apps in the App Store access only the production environment. Before publishing, deploy the development schema to production.
Key rules:
- Every deploy merges additive changes into production
- You cannot delete record types or fields already in production
- Apps in development can access either environment
Reset the Development Environment
Resets all records in the development environment. If schema isn't in production, also deletes all record types.
Steps:
- Sign in to CloudKit Console
- Select CloudKit Database app → your container
- Select Reset Environment (left sidebar)
- Read the warning, check the box, click Reset
Deploy the Development Schema
Copies record types, fields, and indexes to production — but not records.
Permissions: You need admin privileges. Individual developers are automatically admin.
Steps:
- Sign in to CloudKit Console
- Select CloudKit Database app → your container
- Select Deploy Schema Changes (left sidebar)
- Review pending changes, click Deploy
CloudKit Console Access
- Click CloudKit Console button in Xcode's iCloud capability section
- Or go directly to icloud.developer.apple.com
- Use to manage schemas, inspect data, view operation logs, and performance telemetry
1---2name: sqd-cloudkit-setup3description: Use when setting up or troubleshooting iCloud/CloudKit configuration for SQLiteData sync — covers enabling iCloud capability, CloudKit entitlements, container creation, Remote Notifications background mode, deploying schema from development to production, and resetting the development environment via CloudKit Console.4---56# CloudKit Setup for SQLiteData78Complete setup guide for CloudKit sync with SQLiteData — from Xcode capabilities through production deployment.910> **SQLiteData context:** These are the infrastructure steps needed before writing any SyncEngine code. After completing setup here, configure `SyncEngine` per `/skill sqd-cloudkit`.1112## Step 1: Enable iCloud Capability13141. Add capability: follow Apple's "Adding capabilities to your app" guide152. Select **iCloud** from Xcode's Capabilities library163. In the **Services** section, check **CloudKit**174. Xcode adds these entitlements automatically:18 - `com.apple.developer.icloud-services`19 - Push Notifications capability (CloudKit uses push to notify of server changes)2021> Removing the iCloud capability in Xcode does **not** auto-disable it in your developer account — you must do that manually.2223### iCloud Services Overview2425| Service | Use Case | Storage |26|---------|----------|---------|27| **Key-value storage** | Small data (preferences), up to 1 MB / 1024 pairs | `NSUbiquitousKeyValueStore` |28| **iCloud Documents** | File-based sync via `UIDocument`/`NSDocument` | Ubiquity container (on-disk) |29| **CloudKit** | Structured data with full schema control + sharing | `CKContainer` databases |3031**For SQLiteData apps, enable CloudKit.**3233### Managing Containers3435After adding iCloud capability, Xcode fetches existing containers from your developer account.3637**To create a new container:**381. Click **Add** (+) below the containers list392. Enter name: must start with `iCloud.` and use reverse DNS (e.g., `iCloud.com.example.myapp`)403. Click **OK**4142**For SQLiteData**, pass it to SyncEngine:43```swift44$0.defaultSyncEngine = try SyncEngine(45 for: $0.defaultDatabase,46 tables: ...,47 containerIdentifier: "iCloud.com.example.myapp" // nil = auto from entitlements48)49```5051## Step 2: Enable Remote Notifications Background Mode52531. Select your project in Xcode's Project navigator542. Select the app target → **Signing & Capabilities**553. Add **Background Modes** capability (if not present)564. Check **Remote notifications**5758This allows CloudKit to silently notify your app of server-side changes, which `SyncEngine` uses to trigger incremental sync.5960> Use sparingly — overuse impacts battery life and device performance.6162### All Background Modes Reference6364| Mode | Info.plist Value | Platforms |65|------|-----------------|-----------|66| Audio, AirPlay, PiP | `audio` | iOS, iPadOS, tvOS, visionOS |67| Location updates | `location` | iOS, iPadOS, watchOS |68| Voice over IP | `voip` | iOS, iPadOS, visionOS, watchOS |69| External accessory | `external-accessory` | iOS, iPadOS |70| Bluetooth LE central | `bluetooth-central` | iOS, iPadOS, visionOS |71| Bluetooth LE peripheral | `bluetooth-peripheral` | iOS, iPadOS |72| Background fetch | `fetch` | iOS, iPadOS, tvOS, visionOS |73| **Remote notifications** | **`remote-notification`** | **iOS, iPadOS, tvOS, visionOS, watchOS** |74| Background processing | `processing` | iOS, iPadOS, tvOS, visionOS |7576## Step 3: Deploy Schema to Production7778During development, you create your schema and test in the **development environment**. Apps in the App Store access only the **production environment**. Before publishing, deploy the development schema to production.7980Key rules:81- Every deploy merges **additive changes** into production82- You **cannot delete** record types or fields already in production83- Apps in development can access either environment8485### Reset the Development Environment8687Resets all records in the development environment. If schema isn't in production, also deletes all record types.8889**Steps:**901. Sign in to [CloudKit Console](https://icloud.developer.apple.com/)912. Select **CloudKit Database** app → your container923. Select **Reset Environment** (left sidebar)934. Read the warning, check the box, click **Reset**9495### Deploy the Development Schema9697Copies record types, fields, and indexes to production — but **not records**.9899> **Permissions:** You need admin privileges. Individual developers are automatically admin.100101**Steps:**1021. Sign in to [CloudKit Console](https://icloud.developer.apple.com/)1032. Select **CloudKit Database** app → your container1043. Select **Deploy Schema Changes** (left sidebar)1054. Review pending changes, click **Deploy**106107## CloudKit Console Access108109- Click **CloudKit Console** button in Xcode's iCloud capability section110- Or go directly to [icloud.developer.apple.com](https://icloud.developer.apple.com/)111- Use to manage schemas, inspect data, view operation logs, and performance telemetry