Install for Swift
Python · Node · Go · Rust · Swift · Dart · JVM · .NET · C++ · Objective-C
See Concepts for the runtime, remote, and synchronization terms used on this page.
Requirements
Section titled “Requirements”Use Swift 5.9 or newer on macOS 11 or newer, or iOS 15 or newer.
Installation
Section titled “Installation”Add the package through Xcode’s File → Add Package Dependencies or through Package.swift.
dependencies: [ .package(url: "https://github.com/potluckdb/potluckdb-swift", from: "0.1.0"),],targets: [ .executableTarget(name: "App", dependencies: [.product(name: "potluckdb", package: "potluckdb-swift")]),]Use the repository URL in the example for Xcode. The package includes the runtime as a binary framework for every supported Apple platform. The storage library has one binary target per platform: a framework on iOS and a dylib on macOS.
A swift build product finds the storage library beside itself. An application bundle finds it in its Frameworks directory. When set, POTLUCKDB_STORAGE_LIBRARY names the library, and the binary does not search. You need no other installation steps.
Remote storage
Section titled “Remote storage”A remote is the shared copy of a database that devices synchronize with. The quickstart uses a directory as its remote.
- To use a storage service, replace the directory constructor with a storage service constructor.
import potluckdb
let remote = try Storage.fromS3(S3Options(bucket: "my-bucket", namespace: "notes", region: "eu-west-1"))let db = try open("app.potluckdb", remote: remote)The rest of the program stays the same. The Google Cloud Storage and Azure Blob Storage constructors use the same form.
A credential chain tries the storage service’s standard sources for credentials. If you do not pass credentials, the constructor uses these sources:
- Environment variables.
- A profile.
- The host’s identity.
- Configure the credential chain before you open the database.
The storage reference gives each constructor’s signature and parameters, including endpoint, region, and forcePathStyle.
Analytics
Section titled “Analytics”Analytical reads use DuckDB, a separate SQL engine for analysis. The core package does not contain DuckDB.
- Download your platform’s library from the analytics engine page.
- Specify the library in the open options.
let options = OpenOptions(analyticalEngine: "/opt/potluckdb/lib/libduckdb.dylib")The analytics engine page lists each file’s URL and digest. POTLUCKDB_DUCKDB_LIBRARY selects a library for every database in the process.
- On iOS, embed the library in the application bundle.
Licensing
Section titled “Licensing”Without a license key, potluckdb uses a trial. The licensing page explains the trial’s length and start, license key sources, and purchase steps.
Continue with the quickstart.