• Start

Languages

/

Swift

Installation

In this section, you will learn how to install the Swift SDK in your project.

Before you can use this SDK in your Swift applications, you need to add it as a dependency and import it into your project. The SDK is distributed via Swift Package Manager.

Add the package to the dependencies array of your Package.swift, then add the SurrealDB product to the dependencies of your target:

// swift-tools-version:6.1
import PackageDescription

let package = Package(
name: "YourApp",
dependencies: [
.package(url: "https://github.com/surrealdb/surrealdb.swift.git", from: "0.1.0"),
],
targets: [
.target(
name: "YourTarget",
dependencies: [
.product(name: "SurrealDB", package: "surrealdb.swift")
]
)
]
)
  1. Open your project and choose File → Add Package Dependencies…

  2. Enter the repository URL https://github.com/surrealdb/surrealdb.swift.git in the search field.

  3. Select a dependency rule (for example Up to Next Major Version) and click Add Package.

  4. Choose the SurrealDB library product and add it to your application target.

Once the package is resolved, import it wherever you need it:

import SurrealDB

See the getting started guide to connect to a database and run your first query.

Was this page helpful?