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.
Create the app
Section titled “Create the app”vaif init --template ios-swift-appRun 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.
What it writes
Section titled “What it writes”| File | Written |
|---|---|
VaifManager.swift | Always |
.env.example | Always |
README-VAIF.md | Always |
README.md | Always |
Add VaifManager.swift to your app target in Xcode.
Install
Section titled “Install”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.
Configure
Section titled “Configure”The project ID and the keys are on Security > Credentials in the console.
| Variable | Value |
|---|---|
VAIF_PROJECT_ID | Your project ID. |
VAIF_PUBLISHABLE_KEY | The 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.