Overview
The Synheart Behavior Swift/iOS SDK provides real-time behavioral signal inference from digital interactions for native iOS applications. It requires synheart-flux (Rust library) for HSI-compliant metrics.Installation
Swift Package Manager
Add to yourPackage.swift or in Xcode (File → Add Packages…):
synheart-flux (required)
The SDK requires synheart-flux for all behavioral and typing metrics:- Download
SynheartFlux.xcframeworkfrom synheart-flux releases. - Add it to your app target (Frameworks, Libraries, and Embedded Content).
- For clipboard_activity_rate and correction_rate in the typing summary, use synheart-flux 0.3.0 or later.
Requirements
- iOS 12.0+
- Swift 5.0+
- Xcode 12.0+
Quick Start
Basic Usage
Session and HSI Output
Typing: clipboard and correction rates
When using synheart-flux 0.3.0+, the typing session summary includes:- clipboard_activity_rate: (copy + paste + cut) / (typing taps + clipboard actions)
- correction_rate: (backspace + delete) / (typing taps + backspace + delete)
behavior.recordCopy()behavior.recordPaste()behavior.recordCut()
UITextField/UITextView that overrides copy(_:), paste(_:), cut(_:)). The Example app uses BehaviorTrackingTextField for this.
Event behavior
- Taps and long press: Not counted when a text field or text view is first responder (keyboard open), so typing is not double-counted as tap events.
- Typing events: Include full metrics (speed, cadence, burstiness, cadence variability, gap ratio, activity ratio, backspace/copy/paste/cut counts).
API summary
| Method / property | Description |
|---|---|
initialize() | Initialize the SDK |
startSession(sessionId?) | Start a session; returns session ID |
endSession(sessionId) | End session and get basic summary |
endSessionWithHsi(sessionId) | End session and get HSI payload + raw JSON (requires Flux) |
setEventHandler(_:) | Set callback for real-time events |
recordCopy() / recordPaste() / recordCut() | Report clipboard actions for typing summary |
isFluxAvailable | Whether synheart-flux is loaded |
getCurrentStats() | Current rolling statistics |
getSessionEvents() | Events for the current session |
Resources
- Repository: synheart-behavior-swift
- Integration guide: INTEGRATION.md
- Flux integration: SYNHEART_FLUX_INTEGRATION.md
Author: Synheart AI Team