Ensembles 3
Local-first sync for Core Data and SwiftData.

This package distributes pre-built XCFrameworks (binary only). Source code is available separately with a premium license. CloudKit and local backends are free to use; other backends require a license key. See Licensing below.
Ensembles is the only local-first sync framework for Core Data and SwiftData. Unlike most sync frameworks, it requires no custom server: your data syncs as opaque files through storage your users already have, whether that is CloudKit, Dropbox, Google Drive, S3, WebDAV, or a custom backend.
Each device keeps a complete copy of the data, so apps work fully offline. Data stays in your users' own accounts, and can be end-to-end encrypted before it ever leaves the device. There is no server to run, and no cloud bill.
Ensembles has synced production apps since 2013, including Agenda. Ensembles 3 is a complete rewrite in Swift, with async/await concurrency and Swift Package Manager distribution, and it is fully backward compatible with Ensembles 2 cloud data.
Why Ensembles?
- Local-first, not offline-first — cloud data is opaque files, not structured records a server indexes and controls. With end-to-end encryption enabled, the storage provider cannot read your data at all.
- No custom server — users sync through their own storage accounts, so there is no server to deploy and no cloud bill. Devices can also sync peer-to-peer via MultipeerConnectivity with no cloud at all.
- Any cloud backend — 15 built-in backends including CloudKit, Dropbox, S3, Google Drive, OneDrive, Box, pCloud, Supabase, and WebDAV. Not locked to iCloud. Implement the
CloudFileSystem protocol (8 methods) to add your own.
- End-to-end encrypted — AES-256-GCM encryption before data leaves the device. No need to rely on Apple's Advanced Data Protection.
- Core Data fidelity — ordered relationships and validation rules are preserved, with no changes to your model required.
- Transparent to your app — Ensembles observes your existing
NSManagedObjectContext saves. You don't need to change your data model or your save logic.
- Automatic conflict resolution — causal revision tracking merges changes deterministically on every device. Delegate hooks let you inspect and repair merged data before it's committed.
Quick Start (Core Data)
CoreDataEnsembleContainer creates a Core Data stack, sets up a delegate, and auto-syncs on save:
import Ensembles
import EnsemblesCloudKit
// modelURL points to the .momd compiled from your .xcdatamodeld
let modelURL = Bundle.main.url(forResource: "Model", withExtension: "momd")!
// The store is placed automatically at Application Support/MainStore.sqlite
let container = CoreDataEnsembleContainer(
name: "MainStore",
modelURL: modelURL,
cloudFileSystem: CloudKitFileSystem(
privateDatabaseForUbiquityContainerIdentifier: "iCloud.com.yourcompany.yourapp",
schemaVersion: .v2
)
)!
For deduplication, conform your NSManagedObject subclass to the Syncable protocol:
class Note: NSManagedObject, Syncable {
static let globalIdentifierKey = "uniqueID"
@NSManaged var uniqueID: String
@NSManaged var title: String
}
That's it. The container automatically attaches to the cloud, syncs on save, on app activation, and on a timer. Remote changes are merged into the container's viewContext automatically.
Pass EnsembleContainerConfiguration(autoSyncPolicy: .manual) to the initializer to disable all automatic syncing and call sync() yourself.
For more control, use CoreDataEnsemble directly — see the Getting Started guide.
Quick Start (SwiftData)
import EnsemblesSwiftData
import EnsemblesCloudKit
// The store is placed automatically at Application Support/MainStore.sqlite
let container = SwiftDataEnsembleContainer(
name: "MainStore",
modelTypes: [Item.self, Tag.self],
cloudFileSystem: CloudKitFileSystem(
privateDatabaseForUbiquityContainerIdentifier: "iCloud.com.yourcompany.yourapp",
schemaVersion: .v2
)
)!