Overview
The Synheart Session Swift SDK provides a native SessionEngine that captures heart rate data, computes session metrics on-device, and optionally fuses behavioral signals alongside HR data. It runs on iOS, macOS, watchOS, and tvOS. The engine is timer-driven, emitting session frames at configurable intervals and delivering a session summary when complete. The SDK supports pluggableBiosignalProvider (for HR sources) and BehaviorProvider (for behavioral signals).
The SDK computes mean HR locally from sampled biosignals. HRV (
rmssd_ms, hr_sdnn_ms, pnn50) and the HSI 1.3 envelope are produced upstream by the Synheart runtime and ingested into the session via ingestHsiMetrics(). Without that ingest call, HRV fields will be 0.0.Installation
Swift Package Manager
Add to yourPackage.swift:
- File > Add Packages…
- Enter:
https://github.com/synheart-ai/synheart-session-swift.git
Requirements
- iOS 13.0+ / macOS 10.15+ / watchOS 6.0+ / tvOS 13.0+
- Swift 5.9+
- Xcode 15.0+
Quick Start
Types
SessionConfig
includeRawSamples: true to enable raw biosignal streaming alongside session frames:
SessionConfig from a dictionary, which is how the WatchConnectivity relay deserializes commands from the phone:
SessionMode
ComputeProfile
SessionError
Event Dictionary Format
TheSessionEngine callback receives [String: Any] dictionaries with a "type" key:
session_started
session_frame
Contains flat metrics computed over the sliding window:biosignal_frame
Emitted whenincludeRawSamples is true. Contains raw biosignal samples for live display:
session_summary
WatchOS Integration
The Swift SDK is designed to run on Apple Watch. A typical setup usesPhoneSessionRelay on the watch to receive commands from the phone and run SessionEngine locally.
Watch-Side Relay
Watch App Entry Point
Phone-Side Relay (iOS Plugin)
The phone-sideWatchSessionRelay sends commands to the watch and receives events back. It is used inside the Flutter iOS plugin to bridge between Dart and watchOS:
XcodeGen Configuration
If you use XcodeGen for your watchOS project, add the SDK as a local package and link WatchConnectivity:Behavioral Signals
TheSessionEngine accepts an optional BehaviorProvider that fuses behavioral data into session frames.
Mock Behavior (Development)
Production (via synheart-behavior)
"behavior" key is only present in frames when a BehaviorProvider is configured and returns data. See the synheart-session-swift repository README for the full list of behavioral fields.
API Reference
SessionEngine
Resources
- Repository: synheart-session-swift
- Issues: GitHub Issues