{"id":970,"url":"https://github.com/realm/realm-swift","last_synced_at":"2026-02-23T03:54:43.163Z","repository":{"id":3025031,"uuid":"4044891","full_name":"realm/realm-swift","owner":"realm","description":"Realm is a mobile database: a replacement for Core Data \u0026 SQLite","archived":false,"fork":false,"pushed_at":"2025-04-16T16:42:22.000Z","size":67581,"stargazers_count":16470,"open_issues_count":457,"forks_count":2169,"subscribers_count":370,"default_branch":"master","last_synced_at":"2025-05-09T00:13:51.625Z","etag":null,"topics":["database","ios","mobile","mobile-database","objective-c","realtime","swift","sync","threadsafe"],"latest_commit_sha":null,"homepage":"https://realm.io","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/realm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2012-04-16T20:06:56.000Z","updated_at":"2025-05-07T17:21:10.000Z","dependencies_parsed_at":"2023-07-05T20:16:36.474Z","dependency_job_id":"27f35b09-8c96-466f-92f6-c4495181fcf3","html_url":"https://github.com/realm/realm-swift","commit_stats":{"total_commits":9625,"total_committers":178,"mean_commits":54.07303370786517,"dds":0.7337142857142858,"last_synced_commit":"1f09fb14dd9d275b5686016fe8508d491b87cb0b"},"previous_names":["realm/realm-cocoa"],"tags_count":425,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realm%2Frealm-swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realm%2Frealm-swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realm%2Frealm-swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realm%2Frealm-swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/realm","download_url":"https://codeload.github.com/realm/realm-swift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253671266,"owners_count":21945400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["database","ios","mobile","mobile-database","objective-c","realtime","swift","sync","threadsafe"],"created_at":"2024-01-05T20:15:35.904Z","updated_at":"2025-12-11T23:01:59.618Z","avatar_url":"https://github.com/realm.png","language":"Objective-C","funding_links":[],"categories":["Database","Libs","Objective-C","Swift","HarmonyOS","数据库管理系统","[Objective-C](#objective-c)","Data and Storage","OOM-Leaks-Crash","Data Storage","Data Persistence"],"sub_categories":["Getting Started","Data Management","Community","Windows Manager","网络服务_其他","Data Persistence"],"readme":"\u003e [!WARNING]\n\u003e We announced the deprecation of Atlas Device Sync + Realm SDKs in September 2024. For more information please see:\n\u003e - [SDK Deprecation](https://www.mongodb.com/docs/atlas/device-sdks/deprecation)\n\u003e - [Device Sync Deprecation](https://www.mongodb.com/docs/atlas/app-services/sync/device-sync-deprecation)\n\u003e\n\u003e For a version of `realm-swift` without sync features, install version 20 or see the `community` branch.\n\n\u003cpicture\u003e\n    \u003csource srcset=\"./media/logo-dark.svg\" media=\"(prefers-color-scheme: dark)\" alt=\"realm by MongoDB\"\u003e\n    \u003cimg src=\"./media/logo.svg\" alt=\"realm by MongoDB\"\u003e\n\u003c/picture\u003e\n\n# About Realm Database\n\nRealm is a mobile database that runs directly inside phones, tablets or wearables.\nThis repository holds the source code for the iOS, macOS, tvOS \u0026 watchOS versions of Realm Swift \u0026 Realm Objective-C.\n\n## Why Use Realm\n\n* **Intuitive to Developers:** Realm’s object-oriented data model is simple to learn, doesn’t need an ORM, and lets you write less code.\n* **Built for Mobile:** Realm is fully-featured, lightweight, and efficiently uses memory, disk space, and battery life.\n* **Designed for Offline Use:** Realm’s local database persists data on-disk, so apps work as well offline as they do online.\n* **[MongoDB Atlas Device Sync](https://www.mongodb.com/docs/atlas/app-services/sync/)**: Makes it simple to keep data in sync across users, devices, and your backend in real-time. Get started for free with [a template application](https://github.com/mongodb/template-app-swiftui-todo) and [create the cloud backend](http://mongodb.com/realm/register?utm_medium=github_atlas_CTA\u0026utm_source=realm_swift_github).\n\n## Object-Oriented: Streamline Your Code\n\nRealm was built for mobile developers, with simplicity in mind. The idiomatic, object-oriented data model can save you thousands of lines of code.\n\n```swift\n// Define your models like regular Swift classes\nclass Dog: Object {\n    @Persisted var name: String\n    @Persisted var age: Int\n}\nclass Person: Object {\n    @Persisted(primaryKey: true) var _id: String\n    @Persisted var name: String\n    @Persisted var age: Int\n    // Create relationships by pointing an Object field to another Class\n    @Persisted var dogs: List\u003cDog\u003e\n}\n// Use them like regular Swift objects\nlet dog = Dog()\ndog.name = \"Rex\"\ndog.age = 1\nprint(\"name of dog: \\(dog.name)\")\n\n// Get the default Realm\nlet realm = try! Realm()\n// Persist your data easily with a write transaction\ntry! realm.write {\n    realm.add(dog)\n}\n```\n## Live Objects: Build Reactive Apps\nRealm’s live objects mean data updated anywhere is automatically updated everywhere.\n```swift\n// Open the default realm.\nlet realm = try! Realm()\n\nvar token: NotificationToken?\n\nlet dog = Dog()\ndog.name = \"Max\"\n\n// Create a dog in the realm.\ntry! realm.write {\n    realm.add(dog)\n}\n\n//  Set up the listener \u0026 observe object notifications.\ntoken = dog.observe { change in\n    switch change {\n    case .change(let properties):\n        for property in properties {\n            print(\"Property '\\(property.name)' changed to '\\(property.newValue!)'\");\n        }\n    case .error(let error):\n        print(\"An error occurred: (error)\")\n    case .deleted:\n        print(\"The object was deleted.\")\n    }\n}\n\n// Update the dog's name to see the effect.\ntry! realm.write {\n    dog.name = \"Wolfie\"\n}\n```\n### SwiftUI\nRealm integrates directly with SwiftUI, updating your views so you don't have to.\n```swift\nstruct ContactsView: View {\n    @ObservedResults(Person.self) var persons\n\n    var body: some View {\n        List {\n            ForEach(persons) { person in\n                Text(person.name)\n            }\n            .onMove(perform: $persons.move)\n            .onDelete(perform: $persons.remove)\n        }.navigationBarItems(trailing:\n            Button(\"Add\") {\n                $persons.append(Person())\n            }\n        )\n    }\n}\n```\n\n## Fully Encrypted\nData can be encrypted in-flight and at-rest, keeping even the most sensitive data secure.\n```swift\n// Generate a random encryption key\nvar key = Data(count: 64)\n_ = key.withUnsafeMutableBytes { (pointer: UnsafeMutableRawBufferPointer) in\n    guard let baseAddress = pointer.baseAddress else {\n        fatalError(\"Failed to obtain base address\")\n    }\n    SecRandomCopyBytes(kSecRandomDefault, 64, baseAddress)\n}\n\n// Add the encryption key to the config and open the realm\nlet config = Realm.Configuration(encryptionKey: key)\nlet realm = try Realm(configuration: config)\n\n// Use the Realm as normal\nlet dogs = realm.objects(Dog.self).filter(\"name contains 'Fido'\")\n```\n\n## Getting Started\n\nWe support installing Realm via Swift Package Manager, CocoaPods, Carthage, or by importing a dynamic XCFramework.\n\nFor more information, see the detailed instructions in our [docs](https://www.mongodb.com/docs/atlas/device-sdks/sdk/swift/install/).\n\nInterested in getting started for free with [a template application](https://github.com/mongodb/template-app-swiftui-todo) that includes a cloud backend and Sync? [Create a MongoDB Atlas Account](http://mongodb.com/realm/register?utm_medium=github_atlas_CTA\u0026utm_source=realm_swift_github).\n\n## Documentation\n\nThe documentation can be found at [mongodb.com/docs/atlas/device-sdks/sdk/swift/](https://www.mongodb.com/docs/atlas/device-sdks/sdk/swift/).\nThe API reference is located at [mongodb.com/docs/realm-sdks/swift/latest/](https://www.mongodb.com/docs/realm-sdks/swift/latest/)\n\n## Getting Help\n\n- **Need help with your code?**: Look for previous questions with the[`realm` tag](https://stackoverflow.com/questions/tagged/realm?sort=newest) on Stack Overflow or [ask a new question](https://stackoverflow.com/questions/ask?tags=realm). For general discussion that might be considered too broad for Stack Overflow, use the [Community Forum](https://developer.mongodb.com/community/forums/tags/c/realm-sdks/58/swift/).\n- **Have a bug to report?** [Open a GitHub issue](https://github.com/realm/realm-swift/issues/new). If possible, include the version of Realm, a full log, the Realm file, and a project that shows the issue.\n- **Have a feature request?** [Open a GitHub issue](https://github.com/realm/realm-swift/issues/new). Tell us what the feature should do and why you want the feature.\n\n## Building Realm\n\nIn case you don't want to use the precompiled version, you can build Realm yourself from source.\n\nPrerequisites:\n\n* Building Realm requires Xcode 14.1 or newer.\n* Building Realm documentation requires [jazzy](https://github.com/realm/jazzy)\n\nOnce you have all the necessary prerequisites, building Realm just takes a single command: `sh build.sh build`.\nYou'll need an internet connection the first time you build Realm to download the core binary.\nThis will produce Realm.xcframework and RealmSwift.xcframework in `build/Release/`.\n\nRun `sh build.sh help` to see all the actions you can perform (build ios/osx, generate docs, test, etc.).\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for more details!\n\n## Code of Conduct\n\nThis project adheres to the [MongoDB Code of Conduct](https://www.mongodb.com/community-code-of-conduct).\nBy participating, you are expected to uphold this code. Please report\nunacceptable behavior to [community-conduct@mongodb.com](mailto:community-conduct@mongodb.com).\n\n## License\n\nRealm Objective-C \u0026 Realm Swift are published under the Apache 2.0 license.\nRealm Core is also published under the Apache 2.0 license and is available\n[here](https://github.com/realm/realm-core).\n\n## Feedback\n\n**_If you use Realm and are happy with it, please consider sending out a tweet mentioning [@realm](https://twitter.com/realm) to share your thoughts!_**\n\n**_And if you don't like it, please let us know what you would like improved, so we can fix it!_**\n\n\u003cimg style=\"width: 0px; height: 0px;\" src=\"https://3eaz4mshcd.execute-api.us-east-1.amazonaws.com/prod?s=https://github.com/realm/realm-swift#README.md\"\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealm%2Frealm-swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frealm%2Frealm-swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealm%2Frealm-swift/lists"}