{"id":32146661,"url":"https://github.com/jayhickey/cirrus","last_synced_at":"2026-02-21T15:02:22.194Z","repository":{"id":37834615,"uuid":"275474188","full_name":"jayhickey/Cirrus","owner":"jayhickey","description":"☁️ Simple CloudKit sync for Codable Swift models","archived":false,"fork":false,"pushed_at":"2023-07-31T18:23:59.000Z","size":68,"stargazers_count":264,"open_issues_count":1,"forks_count":13,"subscribers_count":7,"default_branch":"main","last_synced_at":"2026-01-15T19:59:37.194Z","etag":null,"topics":["apple","cloudkit","icloud","ios","ipados","macos","swift","watchos"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jayhickey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-28T00:05:52.000Z","updated_at":"2026-01-10T12:42:12.000Z","dependencies_parsed_at":"2022-07-16T09:30:42.745Z","dependency_job_id":null,"html_url":"https://github.com/jayhickey/Cirrus","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/jayhickey/Cirrus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayhickey%2FCirrus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayhickey%2FCirrus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayhickey%2FCirrus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayhickey%2FCirrus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jayhickey","download_url":"https://codeload.github.com/jayhickey/Cirrus/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayhickey%2FCirrus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29684075,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T14:31:22.911Z","status":"ssl_error","status_checked_at":"2026-02-21T14:31:22.570Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apple","cloudkit","icloud","ios","ipados","macos","swift","watchos"],"created_at":"2025-10-21T08:20:12.852Z","updated_at":"2026-02-21T15:02:22.186Z","avatar_url":"https://github.com/jayhickey.png","language":"Swift","readme":"# ☁️ Cirrus\n\n[![SPM](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](#installation)\n[![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](#license)\n[![CI](https://github.com/jayhickey/Cirrus/workflows/CI/badge.svg)](https://github.com/jayhickey/Cirrus/actions?query=workflow%3ACI)\n\nCirrus provides simple [CloudKit](https://developer.apple.com/documentation/cloudkit) sync for [`Codable`](https://developer.apple.com/documentation/swift/codable) Swift models. Rather than support every CloudKit feature, Cirrus is opinionated and prioritizes simplicity, reliability, and ergonomics with Swift value types.\n\n|         | Main Features  |\n----------|-----------------\n\u0026#128581; | No more dealing with `CKRecord`, `CKOperation`, or `CKSubscription`\n\u0026#128064; | Observe models and iCloud account changes with [Combine](https://developer.apple.com/documentation/combine)\n\u0026#128242; | Automatic CloudKit push notification subscriptions\n\u0026#128640; | Clean architecture with concise but powerful API\n\u0026#127873; | Self-contained, no external dependencies\n\n## Usage\n\nAfter [installing](#installation) and following Apple's steps for [Enabling CloudKit in Your App](https://developer.apple.com/library/archive/documentation/DataManagement/Conceptual/CloudKitQuickStart/EnablingiCloudandConfiguringCloudKit/EnablingiCloudandConfiguringCloudKit.html):\n\n1. Register your app for remote CloudKit push notifications\n\n```swift\n// AppDelegate.swift\nfunc application(\n  _ application: UIApplication,\n  didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?\n) -\u003e Bool {\n  ...\n  application.registerForRemoteNotifications()\n  ...\n}\n```\n\n2. Conform your model(s) to `CloudKitCodable`\n\n```swift\nimport CloudKitCodable\n\nstruct Landmark: CloudKitCodable {\n  struct Coordinate: Codable {\n    let latitude: Double\n    let longitude: Double\n  }\n\n  let identifier: UUID\n  let name: String\n  let coordinate: Coordinate\n\n  // MARK: - CloudKitCodable\n\n  /// A key that uniquely identifies the model. Use this identifier to update your \n  /// associated local models when the sync engine emits changes.\n  var cloudKitIdentifier: CloudKitIdentifier {\n    return identifier.uuidString\n  }\n\n  /// Managed by the sync engine, this should be set to nil when creating a new model.\n  /// Be sure to save this when persisting models locally.\n  var cloudKitSystemFields: Data? = nil\n\n  /// Describes how to handle conflicts between client and server models.\n  public static func resolveConflict(clientModel: Self, serverModel: Self) -\u003e Self? {\n\n    // Use `cloudKitLastModifiedDate` to check when models were last saved to the server\n    guard let clientDate = clientModel.cloudKitLastModifiedDate,\n      let serverDate = serverModel.cloudKitLastModifiedDate else {\n      return clientModel\n    }\n    return clientDate \u003e serverDate ? clientModel : serverModel\n  }\n}\n```\n\n3. Initialize a `SyncEngine` for the model\n\n```swift\nimport Cirrus\n\nlet syncEngine = SyncEngine\u003cLandmark\u003e()\n```\n\n4. Configure the `SyncEngine` to process remote changes\n\n```swift\n// AppDelegate.swift\nfunc application(\n  _ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]\n) {\n  syncEngine.processRemoteChangeNotification(with: userInfo)\n  ...\n}\n```\n\n5. Start syncing\n\n```swift\n// Upload new or updated models\nsyncEngine.upload(newLandmarks)\n\n// Delete models\nsyncEngine.delete(oldLandmark)\n\n// Observe remote model changes\nsyncEngine.modelsChanged\n  .sink { change in\n    // Update local models\n    switch change {\n    case let .updated(models):\n      ...\n    case let .deleted(modelIDs):\n      ...\n    }\n  }\n\n// Observe iCloud account status changes\nsyncEngine.$accountStatus\n  .sink { accountStatus in\n    switch accountStatus {\n      case .available:\n        ...\n      case .noAccount:\n        ...\n      ...\n    }\n  }\n```\n\nAnd that's it! Cirrus supports syncing multiple model types too, just initialize and configure a new `SyncEngine` for every type you want to sync.\n\nTo see an example of how Cirrus can be integrated into an app, clone this repository and open the [CirrusExample](https://github.com/jayhickey/Cirrus/tree/main/Example) Xcode project.\n\n## Installation\n\nYou can add Cirrus to an Xcode project by adding it as a package dependency.\n\n  1. From the **File** menu, select **Swift Packages › Add Package Dependency…**\n  2. Enter \"https://github.com/jayhickey/cirrus\" into the package repository URL text field\n  3. Depending on how your project is structured:\n      - If you have a single application target that needs access to the library, add both **Cirrus** and **CloudKitCodable** directly to your application.\n      - If you have multiple targets where your models are in one target but you would like to handle syncing with Cirrus in another, then add **CloudKitCodable** to your model target and **Cirrus** to your syncing target.\n\n## Limitations\n\nCirrus only supports private iCloud databases. If you need to store data in a public iCloud database, Cirrus is not the right tool for you.\n\nNested `Codable` types on `CloudKitCodable` models will _not_ be stored as separate `CKRecord` references; they are saved as `Data` blobs on the top level `CKRecord`. This leads to two important caveats:\n\n1. `CKRecord` has a [1 MB data limit](https://developer.apple.com/documentation/cloudkit/ckrecord), so large models may not fit within a single record. The `SyncEngine` will not attempt to sync any models that are larger than 1 MB. If you are hitting this limitation, consider normalizing your data by creating discrete `CloudKitCodable` models that have identifier references to each other. You can use multiple `SyncEngine`s to sync each model type.\n2. If any child models have properties that reference on-disk file URLs, they will not be converted into `CKAsset`s and stored in CloudKit. If you have a need to store files that are referenced by local file URLs on child models, you can override the `Encodable` `encode(to:)` and `Decodable` `init(from:)` methods on your model to set the file URLs as keys on the coding container of the top level `CloudKitCodable` type. The `SyncEngine` will then be able to sync your files to iCloud.\n\n## License\n\nThis library is released under the MIT license. See [LICENSE](LICENSE) for details.\n\n## 🙌 Special Thanks\n\nThanks to [Tim Bueno](https://github.com/timbueno) for helping to build Cirrus.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjayhickey%2Fcirrus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjayhickey%2Fcirrus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjayhickey%2Fcirrus/lists"}