[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-93804":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":9,"totalLinesOfCode":9,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":9,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":16,"stars30d":16,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":17,"rankGlobal":9,"rankLanguage":9,"license":9,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":18,"hasPages":18,"topics":9,"createdAt":9,"pushedAt":9,"updatedAt":20,"readmeContent":21,"aiSummary":22,"trendingCount":16,"starSnapshotCount":16,"syncStatus":23,"lastSyncTime":24,"discoverSource":25},93804,"sqlite-data","pointfreeco\u002Fsqlite-data","pointfreeco","A fast, lightweight replacement for SwiftData, powered by SQL and supporting CloudKit synchronization.",null,"https:\u002F\u002Fgithub.com\u002Fpointfreeco\u002Fsqlite-data","Swift",1867,129,21,5,0,51.34,false,"main","2026-09-21 04:01:26","# SQLiteData\n\nA [fast](#Performance), lightweight replacement for SwiftData, powered by SQL and supporting\nCloudKit synchronization.\n\n[![](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fdocumentation-gray?logo=swift&logoColor=white)](https:\u002F\u002Fswiftpackageindex.com\u002Fpointfreeco\u002Fsqlite-data\u002Fmain\u002Fdocumentation\u002Fsqlitedata)\n[![CI](https:\u002F\u002Fgithub.com\u002Fpointfreeco\u002Fsqlite-data\u002Factions\u002Fworkflows\u002Fci.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fpointfreeco\u002Fsqlite-data\u002Factions\u002Fworkflows\u002Fci.yml)\n[![Slack](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fslack-chat-informational.svg?label=Slack&logo=slack)](https:\u002F\u002Fwww.pointfree.co\u002Fslack-invite)\n[![](https:\u002F\u002Fimg.shields.io\u002Fendpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fpointfreeco%2Fsqlite-data%2Fbadge%3Ftype%3Dswift-versions)](https:\u002F\u002Fswiftpackageindex.com\u002Fpointfreeco\u002Fsqlite-data)\n[![](https:\u002F\u002Fimg.shields.io\u002Fendpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fpointfreeco%2Fsqlite-data%2Fbadge%3Ftype%3Dplatforms)](https:\u002F\u002Fswiftpackageindex.com\u002Fpointfreeco\u002Fsqlite-data)\n\n  * [Learn more](#Learn-more)\n  * [Overview](#Overview)\n  * [Quick start](#Quick-start)\n  * [Performance](#Performance)\n  * [SQLite knowledge required](#SQLite-knowledge-required)\n  * [Overview](#Overview)\n  * [Demos](#Demos)\n  * [Documentation](#Documentation)\n  * [Installation](#Installation)\n  * [Community](#Community)\n  * [License](#License)\n\n## Learn more\n\nThis library was motivated and designed over the course of many episodes on\n[Point-Free](https:\u002F\u002Fwww.pointfree.co), a video series exploring advanced programming topics in the\nSwift language, hosted by [Brandon Williams](https:\u002F\u002Ftwitter.com\u002Fmbrandonw) and\n[Stephen Celis](https:\u002F\u002Ftwitter.com\u002Fstephencelis). To support the continued development of this\nlibrary, [subscribe today](https:\u002F\u002Fwww.pointfree.co\u002Fpricing).\n\n\u003Ca href=\"https:\u002F\u002Fwww.pointfree.co\u002Fcollections\u002Fmodern-persistence\">\n  \u003Cimg alt=\"video poster image\" src=\"https:\u002F\u002Fd3rccdn33rt8ze.cloudfront.net\u002Fepisodes\u002F0325.jpeg\" width=\"600\">\n\u003C\u002Fa>\n\n## Overview\n\nSQLiteData is a [fast](#performance), lightweight replacement for SwiftData, including CloudKit\nsynchronization (and even CloudKit sharing), built on top of the popular [GRDB] library.\nTo populate data from the database you can use `@Table` and `@FetchAll`, which are\nsimilar to SwiftData's `@Model` and `@Query`:\n\n\u003Ctable>\n\u003Ctr>\n\u003Cth>SQLiteData\u003C\u002Fth>\n\u003Cth>SwiftData\u003C\u002Fth>\n\u003C\u002Ftr>\n\u003Ctr valign=top>\n\u003Ctd width=415>\n\n```swift\n@FetchAll\nvar items: [Item]\n\n@Table\nstruct Item {\n  let id: UUID\n  var title = \"\"\n  var isInStock = true\n  var notes = \"\"\n}\n```\n\n\u003C\u002Ftd>\n\u003Ctd width=415>\n\n```swift\n@Query\nvar items: [Item]\n\n@Model\nclass Item {\n  var title: String\n  var isInStock: Bool\n  var notes: String\n  init(\n    title: String = \"\",\n    isInStock: Bool = true,\n    notes: String = \"\"\n  ) {\n    self.title = title\n    self.isInStock = isInStock\n    self.notes = notes\n  }\n}\n```\n\n\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftable>\n\nBoth of the above examples fetch items from an external data store using Swift data types, and both\nare automatically observed by SwiftUI so that views are recomputed when the external data changes,\nbut SQLiteData is powered directly by SQLite and is usable from UIKit, `@Observable` models, and\nmore.\n\nFor more information on SQLiteData's querying capabilities, see\n[Fetching model data][fetching-article].\n\n## Quick start\n\nBefore SQLiteData's property wrappers can fetch data from SQLite, you need to provide–at\nruntime–the default database it should use. This is typically done as early as possible in your\napp's lifetime, like the app entry point in SwiftUI, and is analogous to configuring model storage\nin SwiftData:\n\n\u003Ctable>\n\u003Ctr>\n\u003Cth>SQLiteData\u003C\u002Fth>\n\u003Cth>SwiftData\u003C\u002Fth>\n\u003C\u002Ftr>\n\u003Ctr valign=top>\n\u003Ctd width=415>\n\n```swift\n@main\nstruct MyApp: App {\n  init() {\n    prepareDependencies {\n      let db = try! DatabaseQueue(\n        \u002F\u002F Create\u002Fmigrate a database\n        \u002F\u002F connection\n      )\n      $0.defaultDatabase = db\n    }\n  }\n  \u002F\u002F ...\n}\n```\n\n\u003C\u002Ftd>\n\u003Ctd width=415>\n\n```swift\n@main\nstruct MyApp: App {\n  let container = {\n    \u002F\u002F Create\u002Fconfigure a container\n    try! ModelContainer(\u002F* ... *\u002F)\n  }()\n\n  var body: some Scene {\n    WindowGroup {\n      ContentView()\n        .modelContainer(container)\n    }\n  }\n}\n```\n\n\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftable>\n\n> [!NOTE]\n> For more information on preparing a SQLite database, see\n> [Preparing a SQLite database][preparing-db-article].\n\nThis `defaultDatabase` connection is used implicitly by SQLiteData's strategies, like\n[`@FetchAll`][fetchall-docs] and [`@FetchOne`][fetchone-docs], which are similar to SwiftData's\n`@Query` macro, but more powerful:\n\n\u003Ctable>\n\u003Ctr>\n\u003Cth>SQLiteData\u003C\u002Fth>\n\u003Cth>SwiftData\u003C\u002Fth>\n\u003C\u002Ftr>\n\u003Ctr valign=top>\n\u003Ctd width=415>\n\n```swift\n@FetchAll\nvar items: [Item]\n\n@FetchAll(Item.order(by: \\.title))\nvar items\n\n@FetchAll(Item.where(\\.isInStock))\nvar items\n\n\n\n@FetchAll(Item.order(by: \\.isInStock))\nvar items\n\n@FetchOne(Item.count())\nvar itemsCount = 0\n\n```\n\n\u003C\u002Ftd>\n\u003Ctd width=415>\n\n```swift\n@Query\nvar items: [Item]\n\n@Query(sort: [SortDescriptor(\\.title)])\nvar items: [Item]\n\n@Query(filter: #Predicate\u003CItem> {\n  $0.isInStock\n})\nvar items: [Item]\n\n\u002F\u002F No @Query equivalent of ordering\n\u002F\u002F by boolean column.\n\n\u002F\u002F No @Query equivalent of counting\n\u002F\u002F entries in database without loading\n\u002F\u002F all entries.\n```\n\n\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftable>\n\nAnd you can access this database throughout your application in a way similar to how one accesses\na model context, via a property wrapper:\n\n\u003Ctable>\n\u003Ctr>\n\u003Cth>SQLiteData\u003C\u002Fth>\n\u003Cth>SwiftData\u003C\u002Fth>\n\u003C\u002Ftr>\n\u003Ctr valign=top>\n\u003Ctd width=415>\n\n```swift\n@Dependency(\\.defaultDatabase)\nvar database\n\nlet newItem = Item(\u002F* ... *\u002F)\ntry database.write { db in\n  try Item.insert { newItem }\n    .execute(db))\n}\n```\n\n\u003C\u002Ftd>\n\u003Ctd width=415>\n\n```swift\n@Environment(\\.modelContext)\nvar modelContext\n\nlet newItem = Item(\u002F* ... *\u002F)\nmodelContext.insert(newItem)\ntry modelContext.save()\n\n```\n\n\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftable>\n\n> [!NOTE]\n> For more information on how SQLiteData compares to SwiftData, see\n> [Comparison with SwiftData][comparison-swiftdata-article].\n\nFurther, if you want to synchronize the local database to CloudKit so that it is available on\nall your user's devices, simply configure a `SyncEngine` in the entry point of the app:\n\n```swift\n@main\nstruct MyApp: App {\n  init() {\n    prepareDependencies {\n      $0.defaultDatabase = try! appDatabase()\n      $0.defaultSyncEngine = SyncEngine(\n        for: $0.defaultDatabase,\n        tables: Item.self\n      )\n    }\n  }\n  \u002F\u002F ...\n}\n```\n\n> [!NOTE]\n> For more information on synchronizing the database to CloudKit and sharing records with iCloud\n> users, see [CloudKit Synchronization].\n\nThis is all you need to know to get started with SQLiteData, but there's much more to learn. Read\nthe [articles][articles] below to learn how to best utilize this library:\n\n  * [Fetching model data][fetching-article]\n  * [Observing changes to model data][observing-article]\n  * [Preparing a SQLite database][preparing-db-article]\n  * [Dynamic queries][dynamic-queries-article]\n  * [CloudKit Synchronization]\n  * [Comparison with SwiftData][comparison-swiftdata-article]\n\n[observing-article]: https:\u002F\u002Fswiftpackageindex.com\u002Fpointfreeco\u002Fsqlite-data\u002Fmain\u002Fdocumentation\u002Fsqlitedata\u002Fobserving\n[dynamic-queries-article]: https:\u002F\u002Fswiftpackageindex.com\u002Fpointfreeco\u002Fsqlite-data\u002Fmain\u002Fdocumentation\u002Fsqlitedata\u002Fdynamicqueries\n[articles]: https:\u002F\u002Fswiftpackageindex.com\u002Fpointfreeco\u002Fsqlite-data\u002Fmain\u002Fdocumentation\u002Fsqlitedata#Essentials\n[comparison-swiftdata-article]: https:\u002F\u002Fswiftpackageindex.com\u002Fpointfreeco\u002Fsqlite-data\u002Fmain\u002Fdocumentation\u002Fsqlitedata\u002Fcomparisonwithswiftdata\n[fetching-article]: https:\u002F\u002Fswiftpackageindex.com\u002Fpointfreeco\u002Fsqlite-data\u002Fmain\u002Fdocumentation\u002Fsqlitedata\u002Ffetching\n[preparing-db-article]: https:\u002F\u002Fswiftpackageindex.com\u002Fpointfreeco\u002Fsqlite-data\u002Fmain\u002Fdocumentation\u002Fsqlitedata\u002Fpreparingdatabase\n[CloudKit Synchronization]: https:\u002F\u002Fswiftpackageindex.com\u002Fpointfreeco\u002Fsqlite-data\u002Fmain\u002Fdocumentation\u002Fsqlitedata\u002Fcloudkit\n[fetchall-docs]: https:\u002F\u002Fswiftpackageindex.com\u002Fpointfreeco\u002Fsqlite-data\u002Fmain\u002Fdocumentation\u002Fsqlitedata\u002Ffetchall\n[fetchone-docs]: https:\u002F\u002Fswiftpackageindex.com\u002Fpointfreeco\u002Fsqlite-data\u002Fmain\u002Fdocumentation\u002Fsqlitedata\u002Ffetchone\n\n## Performance\n\nSQLiteData leverages high-performance decoding from [StructuredQueries][] to turn fetched data into\nyour Swift domain types, and has a performance profile similar to invoking SQLite's C APIs directly.\n\nSee the following benchmarks against\n[Lighter's performance test suite](https:\u002F\u002Fgithub.com\u002FLighter-swift\u002FPerformanceTestSuite) for a\ntaste of how it compares:\n\n```\nOrders.fetchAll                           setup    rampup   duration\n   SQLite (generated by Enlighter 1.4.10) 0        0.144    7.183\n   Lighter (1.4.10)                       0        0.164    8.059\n┌──────────────────────────────────────────────────────────────────┐\n│  SQLiteData (1.0.0)                     0        0.172    8.511  │\n└──────────────────────────────────────────────────────────────────┘\n   GRDB (7.4.1, manual decoding)          0        0.376    18.819\n   SQLite.swift (0.15.3, manual decoding) 0        0.564    27.994\n   SQLite.swift (0.15.3, Codable)         0        0.863    43.261\n   GRDB (7.4.1, Codable)                  0.002    1.07     53.326\n```\n\n## SQLite knowledge required\n\nSQLite is one of the\n[most established and widely distributed](https:\u002F\u002Fwww.sqlite.org\u002Fmostdeployed.html) pieces of\nsoftware in the history of software. Knowledge of SQLite is a great skill for any app developer to\nhave, and this library does not want to conceal it from you. So, we feel that to best wield this\nlibrary you should be familiar with the basics of SQLite, including schema design and normalization,\nSQL queries, including joins and aggregates, and performance, including indices.\n\nWith some basic knowledge you can apply this library to your database schema in order to query\nfor data and keep your views up-to-date when data in the database changes, and you can use\n[StructuredQueries][] to build queries, either using its type-safe, discoverable\n[query building APIs][], or using its `#sql` macro for writing [safe SQL strings][].\n\nFurther, this library is built on the popular and battle-tested [GRDB] library for\ninteracting with SQLite, such as executing queries and observing the database for changes.\n\n[StructuredQueries]: https:\u002F\u002Fgithub.com\u002Fpointfreeco\u002Fswift-structured-queries\n[GRDB]: https:\u002F\u002Fgithub.com\u002Fgroue\u002FGRDB.swift\n[query building APIs]: https:\u002F\u002Fswiftpackageindex.com\u002Fpointfreeco\u002Fswift-structured-queries\u002F~\u002Fdocumentation\u002Fstructuredqueriescore\n[safe SQL strings]: https:\u002F\u002Fswiftpackageindex.com\u002Fpointfreeco\u002Fswift-structured-queries\u002F~\u002Fdocumentation\u002Fstructuredqueriescore\u002Fsafesqlstrings\n\n## Demos\n\nThis repo comes with _lots_ of examples to demonstrate how to solve common and complex problems with\nSQLiteData. Check out [this](.\u002FExamples) directory to see them all, including:\n\n* [**Case Studies**](.\u002FExamples\u002FCaseStudies)\n  \u003Cbr> Demonstrates how to solve some common application problems in an isolated environment, in\n  both SwiftUI and UIKit. Things like animations, dynamic queries, database transactions, and more.\n\n* [**CloudKitDemo**](.\u002FExamples\u002FCloudKitDemo)\n  \u003Cbr> A simplified demo that shows how to synchronize a SQLite database to CloudKit and how to\n  share records with other iCloud users. See our dedicated articles on [CloudKit Synchronization]\n  and [CloudKit Sharing] for more information.\n\n  [CloudKit Synchronization]: https:\u002F\u002Fswiftpackageindex.com\u002Fpointfreeco\u002Fsqlite-data\u002Fmain\u002Fdocumentation\u002Fsqlitedata\u002Fcloudkit\n  [CloudKit Sharing]: https:\u002F\u002Fswiftpackageindex.com\u002Fpointfreeco\u002Fsqlite-data\u002Fmain\u002Fdocumentation\u002Fsqlitedata\u002Fcloudkitsharing\n\n* [**Reminders**](.\u002FExamples\u002FReminders)\n  \u003Cbr> A rebuild of Apple's [Reminders][reminders-app-store] app that uses a SQLite database to\n  model the reminders, lists and tags. It features many advanced queries, such as searching, stats\n  aggregation, and multi-table joins. It also features CloudKit synchronization and sharing.\n\n* [**SyncUps**](.\u002FExamples\u002FSyncUps)\n  \u003Cbr> This application is a faithful reconstruction of one of Apple's more interesting sample\n  projects, called [Scrumdinger][scrumdinger], and uses SQLite to persist the data for meetings.\n  We have also added CloudKit synchronization so that all changes are automatically made available\n  on all of the user's devices.\n\n[Scrumdinger]: https:\u002F\u002Fdeveloper.apple.com\u002Ftutorials\u002Fapp-dev-training\u002Fgetting-started-with-scrumdinger\n[reminders-app-store]: https:\u002F\u002Fapps.apple.com\u002Fus\u002Fapp\u002Freminders\u002Fid1108187841\n\n## Documentation\n\nThe documentation for releases and `main` are available here:\n\n  * [`main`](https:\u002F\u002Fswiftpackageindex.com\u002Fpointfreeco\u002Fsqlite-data\u002Fmain\u002Fdocumentation\u002Fsqlitedata\u002F)\n  * [1.x.x](https:\u002F\u002Fswiftpackageindex.com\u002Fpointfreeco\u002Fsqlite-data\u002F~\u002Fdocumentation\u002Fsqlitedata\u002F)\n\n## Installation\n\nYou can add SQLiteData to an Xcode project by adding it to your project as a package…\n\n> https:\u002F\u002Fgithub.com\u002Fpointfreeco\u002Fsqlite-data\n\n…and adding the `SQLiteData` product to your target.\n\nIf you want to use SQLiteData in a [SwiftPM](https:\u002F\u002Fswift.org\u002Fpackage-manager\u002F) project, it's as\nsimple as adding it to your `Package.swift`:\n\n``` swift\ndependencies: [\n  .package(url: \"https:\u002F\u002Fgithub.com\u002Fpointfreeco\u002Fsqlite-data\", from: \"1.0.0\")\n]\n```\n\nAnd then adding the following product to any target that needs access to the library:\n\n```swift\n.product(name: \"SQLiteData\", package: \"sqlite-data\"),\n```\n\n## Community\n\nIf you want to discuss this library or have a question about how to use it to solve a particular\nproblem, there are a number of places you can discuss with fellow\n[Point-Free](http:\u002F\u002Fwww.pointfree.co) enthusiasts:\n\n  * For long-form discussions, we recommend the\n    [discussions](http:\u002F\u002Fgithub.com\u002Fpointfreeco\u002Fsqlite-data\u002Fdiscussions) tab of this repo.\n\n  * For casual chat, we recommend the\n    [Point-Free Community Slack](http:\u002F\u002Fwww.pointfree.co\u002Fslack-invite).\n\n## License\n\nThis library is released under the MIT license. See [LICENSE](LICENSE) for details.\n","SQLiteData 是一个基于 SQLite 的 Swift 原生数据持久化框架，旨在作为 SwiftData 的轻量、高性能替代方案，同时原生支持 CloudKit 同步与共享。它采用声明式 API（如 @Table 和 @FetchAll），底层依托 GRDB 实现高效 SQL 操作，无需手动编写 SQL 即可完成模型定义与查询；相比 SwiftData，启动更快、内存占用更低，且对数据库结构有更强控制力。适用于需要本地优先、离线可用、跨设备同步（尤其是 iCloud 用户场景）的 iOS\u002FmacOS 应用，尤其适合重视性能与确定性行为的中大型 Swift 项目。",2,"2026-07-25 02:30:07","trending"]