iOS quickstart (Swift)
Add Sovaria to a Swift app: install with SwiftPM, connect, sign in, read data, and keep the session in the Keychain.
Install
Add the package in Xcode (File › Add Packages) or in Package.swift.
.package(url: "https://github.com/sovaria/sovaria-swift.git", from: "1.0.0")Register your app
Console › Authentication › Mobile › Apps: add the iOS bundle id + team id and a redirect URI such as
com.example.app://auth-callback.Connect
import Sovaria let sovaria = try await Sovaria.initialize( url: "https://<ref>.sovarias.in", // Project settings › API anonKey: "svr_anon_…", // public; safe to ship in the app storage: KeychainStore(), // Keychain (see below) device: SovariaDevice(id: deviceId, platform: "ios", name: deviceName) )Keep the session in the Keychain
final class KeychainStore: SessionStorage { func read(_ key: String) async -> String? { /* Keychain read */ } func write(_ key: String, _ value: String) async { /* Keychain write */ } func delete(_ key: String) async { /* Keychain delete */ } }Sign in and use data
try await sovaria.auth.signInWithPassword(email: email, password: password) let todos = try await sovaria.db.select("todos", where: ["done": false], orderBy: "created_at", limit: 20) try await sovaria.files.upload("avatars", "(sovaria.auth.currentSession!.userId!)/me.png", data, contentType: "image/png") let channel = sovaria.realtime.channel("room:42") { message in print(message) } try await channel.send(["text": "hi"])
Every operation
sovaria.api.call(method, path, …) reaches every Sovaria operation, generated from the same description as the JavaScript, Python and Dart SDKs. Ergonomic wrappers: auth, db, files, functions, realtime.
Errors are SovariaError with status, code (PLAN_LIMIT_REACHED, PKCE_REQUIRED, APP_ATTESTATION_REQUIRED…) and a plain message. Foundation only — no third-party dependencies; iOS 15+/macOS 12+.
Something unclear or missing on this page?Tell us