RORK LABJP
CLOUD — Rork Max compiles native Swift on a fleet of cloud Macs, so you never download Xcode or need to own a MacPLATFORM — Rork Max targets iPhone, iPad, Apple Watch, and Vision Pro, and reaches games, widgets, and Live ActivitiesSHIP — Build in the browser, preview through a streaming simulator, install on device via QR code, and submit to the App Store without leaving RorkSPLIT — Regular Rork generates cross-platform apps with React Native and Expo. Reach for it to ship broadly and fast, and for Max when you need Apple-specific depthCREDIT — The free tier works out to roughly five prompts a week. It helps to budget the cost of trying something separately from the cost of finishing itPRICE — Rork Max sits on the $200/month Max plan, while regular Rork starts free with paid plans from $25/monthCLOUD — Rork Max compiles native Swift on a fleet of cloud Macs, so you never download Xcode or need to own a MacPLATFORM — Rork Max targets iPhone, iPad, Apple Watch, and Vision Pro, and reaches games, widgets, and Live ActivitiesSHIP — Build in the browser, preview through a streaming simulator, install on device via QR code, and submit to the App Store without leaving RorkSPLIT — Regular Rork generates cross-platform apps with React Native and Expo. Reach for it to ship broadly and fast, and for Max when you need Apple-specific depthCREDIT — The free tier works out to roughly five prompts a week. It helps to budget the cost of trying something separately from the cost of finishing itPRICE — Rork Max sits on the $200/month Max plan, while regular Rork starts free with paid plans from $25/month
Articles/Dev Tools
Dev Tools/2026-06-16Advanced

Designing CloudKit Sync in a Rork Max Native App — Handling Conflicts and Deletes

You want the same data on iPhone and iPad. When you add CloudKit to a Swift app generated by Rork Max, the hard part is not saving — it is conflicts and deletes. Here are the design decisions I settled on.

Rork Max231CloudKitSwift48Sync2Architecture21

Premium Article

Sync Is Not Done When It "Saves"

You add a favorite on iPhone, but it is missing on iPad. Or something you deleted on iPad comes back to the iPhone a while later. When I added sync to a native Swift app generated by Rork Max, this kind of inconsistency was the first thing I hit.

The code to save a record to CloudKit is straightforward. The hard part is the design: conflicts when several devices write at once, and how to propagate a delete to every device. Ship with that left vague and, to the user, it looks like "an app where data spontaneously appears and disappears." From my experience as an indie developer running apps over a long stretch, what erodes trust is not crashes so much as this kind of quiet inconsistency. Here are the decisions I locked in.

First, Draw the Line Between KV Store and CloudKit

iCloud sync offers several options. For small data like settings, NSUbiquitousKeyValueStore is enough — a lightweight mechanism that syncs key-value pairs only. Its capacity is around 1 MB, and it is not suited to a collection of structured records.

For data whose count grows — items the user creates like notes, favorites, collections — put it in CloudKit with CKRecord. My line: "fixed count addressable by key, use the KV store; variable count you will want to query, use CloudKit." Make that call up front, or you will later cram records into the KV store and break.

Saving a CloudKit record looks like this:

import CloudKit
 
struct FavoriteRecord {
    let id: CKRecord.ID
    var title: String
    var updatedAt: Date
}
 
func save(_ favorite: FavoriteRecord) async throws {
    let db = CKContainer.default().privateCloudDatabase
    let record = CKRecord(recordType: "Favorite", recordID: favorite.id)
    record["title"] = favorite.title
    record["updatedAt"] = favorite.updatedAt
    _ = try await db.save(record)
}

That part is easy. The trouble is what comes next.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
Understand the boundary between NSUbiquitousKeyValueStore and CloudKit (CKRecord), and decide which to use
Learn the code to resolve conflicts when two devices edit the same record, using the server change token and changeTag
Reproduce the tombstone pattern that prevents 'zombie resurrection' when syncing deletes
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Rork Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

Dev Tools2026-07-16
Regenerable Zones in Rork Max Code: Keeping the Freedom to Rebuild
Generated code carries an invisible asset: the option to throw it away and rebuild it. Every hand edit quietly expires that option. Here is how I track it with a ledger and CI checks across six live apps.
Dev Tools2026-06-15
Drawing the Line Between Rork Max's Swift Output and the Expo Build
Rork Max now generates native Swift, while the standard Rork keeps producing Expo (React Native) apps. Here is how to split responsibilities between the two engines inside a single app business, viewed from real maintenance cost.
Dev Tools2026-07-18
Your AR Furniture Is Gone by Morning — Persisting Placements with ARWorldMap
AR apps generated by Rork Max lose every placed object on relaunch. Here is the design that fixes it: when to save an ARWorldMap, how to encode custom anchors, how to handle the relocalization wait, and what to do when relocalization simply never lands.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →