Skip to main content
This page takes you from an empty app to a 60-second reading that returns heart rate, HRV (RMSSD), SDNN and breathing rate on an iPhone.

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
In Xcode, choose File > Add Package Dependencies, enter 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
The repository holds only 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
Motion access shows no prompt. Wording and review notes.

Activate

Keep the key in a Secrets.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

In UIKit, present 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, onError fires when the user leaves the flow (callbacks and options).

Option B: your own screens

Ask for camera access, subscribe to events, then call start() (Starting a session).
To show the fingertip, host the session’s previewLayer in a view that lays it out:
Apps that link 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.

Save the result

Formats and storage: Result JSON. Display rules: Presenting the numbers.