Swift SDK
Get started with the SmartSpectra Swift SDK for iOS — iOS 17+.
Supported Platforms
| Phone | Notes |
|---|---|
| iPhone XS or newer | Tested on iPhone SE 3, 16, 17 |
Installation
Prerequisites
- iOS 17.0 or later (Tested on iPhone SE 3, 16, 17)
- Xcode 16.0 or later
- Physical device for live camera measurements
- API Key from physiology.presagetech.com — see Authentication
- In Xcode, go to File → Add Package Dependencies...
- Enter:
https://github.com/Presage-Security/SmartSpectra-Swift/ - Select Branch → main
NOTE: For production releases, use the defaultmainbranch or select a stable version such as3.0.0. Themainbranch is updated only for final public releases. For release candidates and other prereleases, select thercbranch. Thercbranch tracks the latest prerelease package manifest, for example3.0.0-rc.14. For reproducible prerelease builds, pin the exact prerelease version when your package manager supports it. - Add to your target
Permissions
In Xcode:
- Select your app target.
- Open the
Infotab. - Add a new row for
Privacy - Camera Usage Description. - Set the value to
This app needs camera access to measure vitals.
If missing, the SDK fails gracefully with a clear error explaining what to add.
Example
Use the following setup and quick-start view to run a basic SmartSpectra integration. You can use the provided SwiftUI for a complete screening flow, or build your own interface around the SDK's observable state and metrics.
Configuration
let sdk = SmartSpectraSDK.sharedsdk.config.apiKey = "YOUR_API_KEY"sdk.config.cameraPosition = .frontsdk.config.imageOutputEnabled = truesdk.config.requestedMetrics = SmartSpectraConfig.breathingMetrics + SmartSpectraConfig.cardioMetricsAuthentication
- API Key: Set
sdk.config.apiKey = "YOUR_KEY" - OAuth: Place
PresageService-Info.plistin your app's root directory. No code needed — OAuth overrides the API key automatically.
Quick Start
import SwiftUIimport SmartSpectrastruct ContentView: View { private let sdk = SmartSpectraSDK.shared init() { sdk.config.apiKey = "YOUR_API_KEY" } var body: some View { VStack { if let image = sdk.imageOutput { Image(uiImage: image).resizable().aspectRatio(contentMode: .fit) } Text("Status: \(String(describing: sdk.processingStatus))") Button(sdk.processingStatus == .running ? "Stop" : "Start") { Task { if sdk.processingStatus == .running { try? await sdk.stop() } else { try? await sdk.start() } } } } }}The SDK ships only the data and lifecycle plane — no SwiftUI views. For a complete screening flow (capture surface, live vitals plot, onboarding, terms-of-service prompts, status overlays), copy the reference implementation from samples/demo-app/UI/ into your project. For a UIKit example that builds the UI from scratch, see samples/uikit-sample/.
Additional Details
Runtime State
SmartSpectraSDK.shared publishes the current SDK state directly:
metricsfor live vitals dataimageOutputfor optional camera preview framesprocessingStatusfor lifecycle updatesvalidationStatusfor readiness hints such as lighting or face positionerrorfor typed runtime failuresinsightfor responses returned fromrequestInsight(_:)
UIKit
UIKit apps can drive the SDK directly through its observable state. Configure the shared SDK, observe imageOutput, metrics, and processingStatus, and call try await sdk.start() / try await sdk.stop() from a @MainActor context. See samples/uikit-sample/ for an example that builds the full UI in UIKit.
Device Orientation
If you copy the sample screening UI, portrait orientation is recommended. Remove "Landscape Left," "Landscape Right," and "Portrait Upside Down" from your supported interface orientations unless your app provides its own landscape layout.
Next Steps
- Use case examples
- Configure which metrics to compute
- Run headless without the built-in UI
- Migration Guide for upgrading from older SDK versions
Documentation
API reference available at Swift API Reference, or build locally via Product → Build Documentation in Xcode.
Troubleshooting
If you're upgrading an older Swift integration, start with the iOS Migration Guide.
For installation, setup, and runtime issues, see the iOS Troubleshooting Guide.
For support: contact support@presagetech.com or submit a GitHub issue.