Sample SwiftUI application showcasing three SmartSpectra Swift SDK 3.0.0 integration patterns:
- Live Vitals Preview - Auto-start a custom live preview with rolling charts for pulse and breathing.
- Vitals Labels - Start SmartSpectra and show a small preview plus pulse, expression, and talking labels.
- Pulse Capture Form - Open an auto-starting pulse capture flow, average confident readings, and drop the accepted result into a read-only form field.
- Xcode 16.0 or later
- iOS 17 or later
- Physical iOS device (camera access is required; the simulator is not supported for real capture)
- SmartSpectra developer account
- SmartSpectra Swift SDK 3.0.0, pinned through Swift Package Manager
- Clone the repository
git clone https://github.com/Presage-Security/SmartSpectraExamples.git cd SmartSpectraExamples - Install credentials
- Sign in (or create an account) at https://physiology.presagetech.com/.
- Register your app in the portal and download the generated
PresageService-Info.plistconfiguration. - In this repo, copy
SmartSpectraExamples/PresageService-Info.example.plisttoSmartSpectraExamples/PresageService-Info.plistand replace the placeholder values with the credentials from the portal. PresageService-Info.plistis intentionally gitignored; do not commit app credentials.
- Open the project
- Double-click
SmartSpectraExamples.xcodeproj, or runxed .from the repo root. - Select the
SmartSpectraExamplestarget, open Signing & Capabilities, choose your Apple Developer team, and use a bundle identifier registered for your account. - If you are contributing back to this repo, leave your local
DEVELOPMENT_TEAMsigning change out of the commit.
- Double-click
- Build on a device
- Connect your iOS device, select it as the run destination, then build and run. Grant camera access when prompted.
If you prefer API-key authentication, set SmartSpectraSDK.shared.config.apiKey = "YOUR_API_KEY" before calling start().
-
Pulse Capture Form
PulseFormExampleViewowns the read-only field and launches a capture sheet.PulseCaptureViewrequests cardio metrics, starts capture automatically, readssdk.metrics?.cardio.pulseRate, and builds aPulseCaptureReadingafter collecting enough confident readings.- Once a reading is ready, Use Reading is the primary action and Redo Capture starts a fresh capture while the camera preview stays live.
ReadOnlyMeasurementFieldgives visual affordance of a text field without allowing manual edits.
-
Live Vitals Preview
- Configures pulse and breathing rate metrics plus pulse and breathing traces for a custom camera-first UI.
- Starts capture automatically when the view appears and stops when it disappears.
- Reads
sdk.validationStatusandsdk.errorfor user-facing capture guidance. - Uses
sdk.metrics?.cardio.pulseRateandsdk.metrics?.breathing.ratefor labels, then plotssdk.metrics?.cardio.arterialPressureTraceandsdk.metrics?.breathing.upperTrace.
-
Vitals Labels
BareBonesVitalsLabelsExampleViewrequests only.pulseRate,.expressions, and.talking.- Shows a small image preview and displays the latest pulse rate, expression, and talking state in plain
LabeledContentrows. - Reads pulse from
sdk.metrics?.cardio.pulseRateand the top expression score fromsdk.metrics?.face.expression.
- Change
sdk.config.requestedMetricsto request only the metric groups your feature needs. - Keep capture calls on the main actor;
SmartSpectraSDKandSmartSpectraConfigare main-actor isolated. - Use
sdk.metrics?.cardio.pulseRatefor pulse rate andsdk.metrics?.breathing.ratefor breathing rate. - Use
sdk.metrics?.face.expressionfor expression scores. - Use
sdk.metrics?.face.talkingfor talking detection. - Use
sdk.config.imageOutputEnabled = trueonly when your UI needs camera preview frames.
- Camera access denied - Users must enable camera permissions in Settings;
CameraPermissionGatesurfaces a prompt if access is missing. - No confident pulse captured - Ensure good lighting and face positioning; the pulse sheet will show an error and allow retry.
- No metrics appear - Check that
sdk.config.requestedMetricsincludes the needed metric group before callingstart(). - Build failures fetching packages - From Xcode, open File > Packages > Reset Package Caches and rebuild.
See LICENSE for license information.