Skip to main content

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 pluggable BiosignalProvider (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 your Package.swift:
Or in Xcode:
  1. File > Add Packages…
  2. 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

Set includeRawSamples: true to enable raw biosignal streaming alongside session frames:
You can also create a SessionConfig from a dictionary, which is how the WatchConnectivity relay deserializes commands from the phone:

SessionMode

ComputeProfile

SessionError

Event Dictionary Format

The SessionEngine callback receives [String: Any] dictionaries with a "type" key:

session_started

session_frame

Contains flat metrics computed over the sliding window:
To extract metrics:

biosignal_frame

Emitted when includeRawSamples is true. Contains raw biosignal samples for live display:
To extract the latest BPM:

session_summary

WatchOS Integration

The Swift SDK is designed to run on Apple Watch. A typical setup uses PhoneSessionRelay 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-side WatchSessionRelay 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

The SessionEngine accepts an optional BehaviorProvider that fuses behavioral data into session frames.

Mock Behavior (Development)

Production (via synheart-behavior)

The "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