libsql-sqlite3 is a Swift package that provides a native wrapper around the libSQL fork of SQLite. This package delivers the power of libSQL – a community-driven, open-contribution fork of SQLite – as a pre-built binary (xcframework).
libSQL is designed to extend SQLite's capabilities while maintaining full compatibility with its file format and C API. With this package, you can harness those improvements directly in your Swift applications.
- iOS: 11.0 or later (adjustable in Package.swift)
- Swift: 5.3 or later
- Xcode: 12 or later
- Open your Xcode project.
- Navigate to File > Swift Packages > Add Package Dependency…
- Enter the repository URL:
https://github.com/emarashliev/libsql-sqlite3.git - Choose your version rule (e.g., "Up to Next Major" starting from 1.0.0) and finish the setup.
Include the package dependency in your Package.swift file as shown below:
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "YourProject",
dependencies: [
.package(url: "https://github.com/emarashliev/libsql-sqlite3.git", branch: "main")
],
targets: [
.target(
name: "YourProject",
dependencies: ["SQLite3"]
)
]
)The repository includes an Example project that demonstrates how to use libsql-sqlite3 in a real iOS application. This sample project shows best practices for integrating and using SQLite with vector extensions in your Swift projects.
To run the example:
- Clone the repository
- Open the
Example/Example.xcodeprojfile in Xcode - Build and run the project
The example demonstrates using vector extensions for similarity search
Use this example as a reference when implementing libsql-sqlite3 in your own projects.
This script builds SQLite3 libraries with vector extension support for iOS platforms. It creates a universal XCFramework that can be used in iOS applications, supporting both device and simulator architectures.
- Clones the libsql repository with vector extensions
- Builds SQLite3 with common extensions (FTS5, JSON1, RTREE, COLUMN_METADATA)
- Creates a universal XCFramework for iOS (arm64) and iOS Simulator (arm64)
- Provides clean-up functionality for build artifacts
- Supports verbose mode for debugging
- macOS development environment
- Xcode command-line tools
- Git
./build.sh [options]| Option | Description |
|---|---|
-h, --help |
Show help message |
-c, --clean-only |
Clean build artifacts without building |
-v, --verbose |
Enable verbose output |
-s, --skip-clone |
Skip repository cloning (use existing) |
The script performs the following steps:
- Repository Cloning: Clones the libsql repository from GitHub, specifically the "vector" branch
- Building:
- Configures and builds the base SQLite3 version
- Builds for iOS device (arm64) with required flags
- Builds for iOS Simulator (arm64) with required flags
- XCFramework Creation: Packages the libraries into a universal XCFramework
- Cleanup: Removes temporary build artifacts
The script generates sqlite3.xcframework in the current directory, which includes:
- Dynamic libraries for iOS (arm64) and iOS Simulator (arm64)
- Headers for SQLite3
The script uses these main configuration variables:
REPO_URL="https://github.com/tursodatabase/libsql.git"
BRANCH="vector"
BUILD_DIR="bld"
OUTPUT_FRAMEWORK="sqlite3.xcframework"
SQLITE_FLAGS="-DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_COLUMN_METADATA"./build.sh./build.sh --clean-only
./build.sh./build.sh --verbose./build.sh --skip-cloneIf you encounter issues:
- Check that Xcode and command-line tools are installed
- Ensure you have internet access for repository cloning
- Run in verbose mode for detailed output:
./build.sh --verbose - Clean build artifacts and try again:
./build.sh --clean-only && ./build.sh
MIT