Skip to content

Repository files navigation

SmartSpectra iOS Examples

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.

Requirements

  • 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

Getting Started

  1. Clone the repository
    git clone https://github.com/Presage-Security/SmartSpectraExamples.git
    cd SmartSpectraExamples
  2. 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.plist configuration.
    • In this repo, copy SmartSpectraExamples/PresageService-Info.example.plist to SmartSpectraExamples/PresageService-Info.plist and replace the placeholder values with the credentials from the portal.
    • PresageService-Info.plist is intentionally gitignored; do not commit app credentials.
  3. Open the project
    • Double-click SmartSpectraExamples.xcodeproj, or run xed . from the repo root.
    • Select the SmartSpectraExamples target, 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_TEAM signing change out of the commit.
  4. 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().

What's Inside Each Demo

  • Pulse Capture Form

    • PulseFormExampleView owns the read-only field and launches a capture sheet.
    • PulseCaptureView requests cardio metrics, starts capture automatically, reads sdk.metrics?.cardio.pulseRate, and builds a PulseCaptureReading after 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.
    • ReadOnlyMeasurementField gives 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.validationStatus and sdk.error for user-facing capture guidance.
    • Uses sdk.metrics?.cardio.pulseRate and sdk.metrics?.breathing.rate for labels, then plots sdk.metrics?.cardio.arterialPressureTrace and sdk.metrics?.breathing.upperTrace.
  • Vitals Labels

    • BareBonesVitalsLabelsExampleView requests only .pulseRate, .expressions, and .talking.
    • Shows a small image preview and displays the latest pulse rate, expression, and talking state in plain LabeledContent rows.
    • Reads pulse from sdk.metrics?.cardio.pulseRate and the top expression score from sdk.metrics?.face.expression.

Customization Tips

  • Change sdk.config.requestedMetrics to request only the metric groups your feature needs.
  • Keep capture calls on the main actor; SmartSpectraSDK and SmartSpectraConfig are main-actor isolated.
  • Use sdk.metrics?.cardio.pulseRate for pulse rate and sdk.metrics?.breathing.rate for breathing rate.
  • Use sdk.metrics?.face.expression for expression scores.
  • Use sdk.metrics?.face.talking for talking detection.
  • Use sdk.config.imageOutputEnabled = true only when your UI needs camera preview frames.

Troubleshooting

  • Camera access denied - Users must enable camera permissions in Settings; CameraPermissionGate surfaces 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.requestedMetrics includes the needed metric group before calling start().
  • Build failures fetching packages - From Xcode, open File > Packages > Reset Package Caches and rebuild.

License

See LICENSE for license information.

About

SwiftUI sample app demonstrating SmartSpectra SDK integrations, from guided captures to embedding vitals in your own forms.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Contributors

Languages