explaingit

stephencelis/sqlite.swift

10,145SwiftAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

A type-safe Swift library for SQLite that lets you define tables and run queries using Swift objects instead of raw SQL strings, catching type errors and typos at compile time, for iOS and Mac apps needing local data storage.

Mindmap

mindmap
  root((SQLite.swift))
    What it does
      Type-safe queries
      Local data storage
      Schema definition
    Features
      Compile-time checks
      Full-text search
      Encrypted databases
      Migrations
    Platforms
      iOS
      macOS
      Linux
    Audience
      Swift developers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Store structured data locally in an iOS or Mac app using a type-safe Swift interface without writing raw SQL strings.

USE CASE 2

Define a database schema with Swift objects so column typos and type mismatches are caught by the compiler before the app runs.

USE CASE 3

Add full-text search or encrypted storage to an iOS app using SQLite.swift alongside the SQLCipher companion library.

Tech stack

SwiftSQLite

Getting it running

Difficulty · easy Time to first run · 30min
MIT license, use freely in any project, including commercial apps, with no restrictions beyond keeping the copyright notice.

In plain English

SQLite.swift is a Swift library for working with SQLite, a file-based database that runs inside your app rather than on a separate server. SQLite is widely used in iOS and Mac apps to store structured data locally on the device, things like user settings, downloaded content, or anything that needs to persist between app launches. What this library adds on top of raw SQLite is a Swift-friendly interface. Instead of writing database queries as plain text strings, which can contain typos or type mistakes that only show up at runtime, you define your tables and columns as Swift objects. The library then catches errors at compile time, before you even run the app. If you try to insert the wrong type of data into a column or misspell a column name, the code will not compile. The API is designed to feel natural in Swift. You create a table definition once, then use it to insert rows, query records with filters, update values, and delete entries. Each operation produces the corresponding SQL behind the scenes, but you do not have to write or read raw SQL unless you want to. The library also supports full-text search, encrypted databases via a companion library called SQLCipher, and database migration tools for updating your schema as your app evolves. Installation works through the standard Swift package tools and also through CocoaPods and Carthage, which are older dependency managers common in Apple platform development. The library works on iOS, macOS, and Linux. It is MIT licensed and well documented, with a playground included in the Xcode project for hands-on exploration. This is a tool for Swift developers building apps that need local data storage without setting up a full database server.

Copy-paste prompts

Prompt 1
Using SQLite.swift, show me how to define a Users table with id, name, and email columns and insert a new user row in Swift.
Prompt 2
How do I query SQLite.swift to fetch all records where a column value matches a filter and map the results to a Swift struct?
Prompt 3
Walk me through setting up SQLite.swift in a new iOS Xcode project using Swift Package Manager and opening a database file.
Prompt 4
Show me how to write a migration in SQLite.swift that adds a new column to an existing table without deleting the current data.
Open on GitHub → Explain another repo

← stephencelis on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.