Sample SwiftUI application showcasing three integration patterns for the SmartSpectra Swift SDK:
- SmartSpectra Capture Experience – Launch the SDK's built-in guided capture UX via
SmartSpectraViewwith minimal configuration. - Pulse Capture Form – Trigger a capture flow, validate the returned reading, and drop the result into a read-only form field.
- Live Vitals Preview – Run a lightweight capture loop with start/stop controls and rolling charts for pulse and breathing traces.
- Xcode 16.0 or later
- iOS 17 (device deployment target is 17.0)
- Physical iOS device (camera access is required; the simulator is not supported)
- SmartSpectra developer account
- Clone the repository
git clone https://github.com/Presage-Security/SmartSpectraSwiftSDK-Examples.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 the provided
SmartSpectraExamples/PresageService-Info.example.plisttoSmartSpectraExamples/PresageService-Info.plistand replace the placeholder values with the credentials from the portal. (The real plist is ignored by source control so you can keep secrets out of git.)
- Open the project
- Double-click
SmartSpectraExamples.xcodeproj, or runxed .from the repo root. - Select the
SmartSpectraExamplestarget and configure your signing team and bundle identifier.
- 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.
Heads up: If you prefer API-key authentication over the portal configuration, call
SmartSpectraSwiftSDK.shared.setApiKey("YOUR_API_KEY")early in your app lifecycle (e.g., inconfigureSdk()insideSmartSpectraExperienceExampleView).
-
SmartSpectra Capture Experience
- Minimal configuration via
SmartSpectraExperienceExampleView.Config(mode, camera, duration, control visibility). - Pulls latest vitals from
SmartSpectraSwiftSDK.shared.metricsBufferto show current pulse/breathing readings.
- Minimal configuration via
-
Live Vitals Preview
- Spins up
SmartSpectraVitalsProcessor.sharedonce on appear, then lets you start/stop recordings without reinitialising the processor. - Uses
VitalsPlotsOverlayto render pulse and breathing rate traces in real time while the camera feed fills the background. VitalsTracePlotViewextends the most recent sample between SDK updates so the charts stay responsive.
- Spins up
-
Pulse Capture Form
PulseFormExampleViewowns the read-only field and launches a capture sheet.PulseCaptureViewcollects data, enforces confidence thresholds, and hands back aPulseCaptureReadingwhen users tap Use Reading.ReadOnlyMeasurementFieldgives visual affordance of a text field without allowing manual edits.
- Adjust
SmartSpectraExperienceExampleView.Configto experiment with mode, camera position, or measurement duration. - The pulse form example stores the latest reading in
PulseCaptureReadingand formats it for display; you can replace the read-only view with your own form controls. PulseCaptureSessionwrapsSmartSpectraSwiftSDK.sharedandSmartSpectraVitalsProcessor.shared. Extend it if you need to stream additional metrics or surface custom status messages.LiveVitalsSessiondemonstrates how to consumeSmartSpectraVitalsProcessorandSmartSpectraSwiftSDKpublishers directly. Tune thewindowSecondsconstant to adjust how much history each chart displays.
- 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 session will return an error label and you can retry the capture.
- Build failures fetching packages – From Xcode, open File ▸ Packages ▸ Reset Package Caches and rebuild.
See LICENSE for license information (update this section to match your project’s license).