Skip to content

iOS app in Swift

Files to add to an Xcode project for iOS or macOS. VaifManager.swift is a shared, observable class that creates the Swift client from your project ID and publishable key, and has helpers to sign in, sign out, and read and insert rows. README-VAIF.md has the setup steps.

Terminal window
vaif init --template ios-swift-app

Run it in a new, empty folder. It writes vaif.config.json and the template's files there. It stops if the folder already has a vaif.config.json, and leaves any other file that already exists alone; --force overwrites both.

This template has no optional features, so it asks nothing.

FileWritten
VaifManager.swiftAlways
.env.exampleAlways
README-VAIF.mdAlways
README.mdAlways

Add VaifManager.swift to your app target in Xcode.

The code this template writes uses the client for its language:

The code builds only once the Swift client can be added to the project. Until then, call the REST API from Swift with URLSession.

The project ID and the keys are on Security > Credentials in the console.

VariableValue
VAIF_PROJECT_IDYour project ID.
VAIF_PUBLISHABLE_KEYThe project's publishable key (vk_pub_). Row rules apply to it, so it is safe in an app.

VaifManager reads both values from the process environment, which you set under Edit Scheme > Run > Arguments > Environment Variables in Xcode, or else from the app’s Info.plist. The scheme’s variables apply only when Xcode runs the app, so use Info.plist for builds you ship.

  • Swift SDK for the client’s state and what it will cover.
  • REST API for every route.