SQLiteData
A fast, lightweight replacement for SwiftData, powered by SQL and supporting CloudKit synchronization.
Learn more
This library was motivated and designed over the course of many episodes on Point-Free, a video series exploring advanced programming topics in the Swift language, hosted by Brandon Williams and Stephen Celis. To support the continued development of this library, subscribe today.
Overview
SQLiteData is a fast, lightweight replacement for SwiftData, including CloudKit synchronization (and even CloudKit sharing) that deploys all the way back to the iOS 13 generation of targets. To populate data from the database you can use @Table and @FetchAll , which are similar to SwiftData's @Model and @Query :
SQLiteData SwiftData @ FetchAll var items : [ Item ] @ Table struct Item { let id : UUID var title = " " var isInStock = true var notes = " " } @ Query var items : [ Item ] @ Model class Item { var title : String var isInStock : Bool var notes : String init ( title : String = " " , isInStock : Bool = true , notes : String = " " ) { self . title = title self . isInStock = isInStock self . notes = notes } }
Both of the above examples fetch items from an external data store using Swift data types, and both are automatically observed by SwiftUI so that views are recomputed when the external data changes, but SQLiteData is powered directly by SQLite and is usable from UIKit, @Observable models, and more.
For more information on SQLiteData's querying capabilities, see Fetching model data.
Quick start
... continue reading