Prerequisites
- An iPhone on iOS 15 or later. The Simulator cannot take a reading.
- Xcode 27 or newer, which needs the UIScene life cycle (Requirements).
- From NEUROFIT: a license key and a download token. The key lists every bundle identifier you run, development ones included (Debug builds).
- The pre-built flow ships in English (localize it).
Install
Give SwiftPM your download token in~/.netrc, then run chmod 600 ~/.netrc:
~/.netrc
https://github.com/neurofit-app-org/vitals-sdk-swift, and add
NeurofitVitals to your app target, plus NeurofitVitalsUI for Option A. Or in Package.swift:
Package.swift
Package.swift. The binaries download from sdk.neurofit.app, pinned by checksum. On
CI, see Download token. Offline builds, your own repository or a source license:
Install from source or manually.
Camera usage
Info.plist
Activate
Keep the key in aSecrets.xcconfig you do not commit (NEUROFIT_VITALS_LICENSE_KEY = <your license key>), set
it as your target’s configuration file, and pass it through Info.plist:
Info.plist
activate throws licenseInvalid with a reason (reasons and fixes). It
also returns warnings, which only a source build in Debug fills (Debug builds).
Option A: pre-built reading flow
VitalsReadingFlowViewController and dismiss it in the callback:
- The flow checks the device and asks for camera access itself, so you don’t need to request it first.
- One of
onComplete,onCancel,onErrorfires when the user leaves the flow (callbacks and options).
Option B: your own screens
Ask for camera access, subscribe to events, then callstart()
(Starting a session).
previewLayer in a view that lays it out:
NeurofitVitalsUI can use VitalsCameraPreviewView (UIKit) or VitalsCameraPreview (SwiftUI),
which also keep the screen awake.
Call stop() when the screen goes away, lock portrait and keep the screen on
(Orientation and screen). Every event:
Reading lifecycle.