hobbysoft.pro

Expertise

iCloud sync with CloudKit for iPhone, iPad and Mac apps

I add iCloud sync to Apple platform apps with CloudKit, so people's data follows them across iPhone, iPad and Mac without an account or a server of your own. My app Haptic Forge syncs its whole library of collections, favorites and recent work through the user's own iCloud.

By HobbySoft, iOS & Mac developer Updated

CloudKit sync development for Apple platforms

CloudKit is Apple’s cloud database. For most apps, its private database is the simplest way to give users sync across their own iPhone, iPad and Mac: no sign-up screen, no backend to run and no user data on servers you manage. Apple hosts it, and the data belongs to the user’s iCloud.

It fits when:

  • Your app is personal or offline-first: notes, libraries, logs, collections, settings.
  • You ship on more than one Apple device and users expect their work everywhere.
  • You want strong privacy without building authentication.

It is the wrong tool when you need Android clients, server-side business logic or reporting across all users. I will tell you that early.

Why sync is harder than it looks

Choosing the sync layer

There are several ways to sync, each with real trade-offs:

ApproachGood forWatch out for
NSPersistentCloudKitContainerExisting Core Data appsLimited control over when and how merges happen
SwiftData with CloudKitNew SwiftUI apps with simple modelsNo unique constraints; properties must be optional or have defaults
CKSyncEngineCustom stores that need controlMore code, you own the state machine
Direct CloudKit operationsSpecial cases, shared or public dataYou handle batching, retries and change tokens

Conflicts are a product question

When two devices change the same record, CloudKit rejects the second save with serverRecordChanged and includes the current server record. The app has to merge: last writer wins for some fields, combine for others (lists, favorites, counters), and never silently drop user work. I define these rules per field while designing the model.

The schema is forever

CloudKit has a development and a production environment. Once a schema is deployed to production, it can only grow: you can add record types and fields, but not remove or rename them. Model changes have to be planned for every version still installed on users’ devices.

Account and network reality

Users sign out of iCloud, switch accounts, run out of storage or go offline for days. The app needs to react to account changes, keep working locally, show sync state honestly and catch up later without duplicates. Large binary data belongs in assets, not in record fields.

Testing with real devices

Sync bugs appear between devices, not in unit tests. I test with several devices on the same account, including offline edits, deletions on one device while another edits, and fresh installs that pull down existing data.

How I use iCloud sync in Haptic Forge

Haptic Forge, my Core Haptics editor for iPhone, iPad and Mac, keeps a library of collections, favorites and recent work, synced through the user’s own iCloud across iPhone, iPad and Mac. There is no account and no server, and patterns stay in the user’s iCloud.

That library is shared by very different devices. On Mac and iPad it sits in a full editor with a sidebar, layer tabs and an inspector, while the iPhone both edits patterns and plays them, since only iPhones can play Core Haptics patterns. A pattern started on the Mac and felt on a paired iPhone, as described in testing haptics on iPhone from a Mac, should show up on every device the user owns. Building one data model for all three platforms is covered on my SwiftUI multiplatform page.

iCloud sync work I take on

  • iCloud sync added to an existing iOS or Mac app, with a migration path for current local data.
  • A sync-ready data model for a new app, designed with conflict rules from the start.
  • Moving from a fragile custom sync to CloudKit, or from one sync layer to another. See app rescue and modernization.
  • Diagnosis of existing sync issues: duplicates, missing records or data that never arrives on the Mac.

Apple’s CloudKit documentation covers the APIs; the hard part is the data design around them.

Plan your sync

Tell me what data your users create and on which devices, at contact@hobbysoft.pro. I will suggest the sync approach that fits and the pitfalls to plan for.

FAQ

Questions and answers

Do users need to create an account for CloudKit sync?

No. CloudKit uses the Apple Account the user is already signed into, and data in the private database counts against that user's iCloud storage. Your app never sees a password.

Can I use CloudKit with Core Data or SwiftData?

Yes. NSPersistentCloudKitContainer syncs Core Data, and SwiftData can sync through CloudKit with some model restrictions. For full control, CKSyncEngine or direct CloudKit calls are the alternatives.

What happens when two devices edit the same item offline?

CloudKit detects the conflict when the second device saves and returns the newer server version. The app then decides how to merge, which is why conflict rules should be designed with the data model, not after it.

Does CloudKit work on Android or the web?

CloudKit is built for Apple platforms. There is a web API, but if your product needs Android clients, a cross-platform backend is usually the better choice.

Have an app in mind? Let’s ship it.

I take on a small number of projects at a time and stay with them to the finish: one accountable developer, an EU company with clear invoicing, and support long after launch.

Hire me