Swift SDK
Install
Section titled “Install”What the next release does
Section titled “What the next release does”The Swift client in development covers your app’s users, table queries, file storage and functions with async/await. It supports iOS 15, macOS 12, tvOS 15, watchOS 8 and visionOS 1 or later, and needs Swift 6. This page describes that client, so you can plan for it. Until it can be installed, call the REST API with URLSession.
import VaifClient
let vaif = try VaifClient(projectId: "YOUR_PROJECT_ID", apiKey: "vk_pub_...")
_ = try await vaif.auth.signIn(email: "ada@example.com", password: "a strong password")
let todos = try await vaif.from("todos") .eq("done", false) .order("created_at", ascending: false) .limit(20) .list()print(todos.count, todos.data)- Auth:
signUp,signIn(which returns a session or a two-factor challenge),verifyMFA,getUser,requestPasswordReset,resetPasswordandsignOut. The access token refreshes itself 30 seconds before it expires, andSessionisCodable, so you can keep it in the Keychain. - Tables:
from(table)with filters, ordering and paging, then reads and writes. - Storage and functions: uploads through a signed URL, downloads, signed links, and function calls.
- Retries:
GET,HEADandOPTIONSrequests are retried on 429 and 5xx responses and on network errors. Writes are never replayed once they may have reached the server. Cancelling the calling task cancels the request.
Use a publishable vk_pub_ key in apps. A secret vk_srv_ key bypasses row rules and must never ship in an app.