← 返回
开发者工具

HealthKit Sync

iOS HealthKit data sync CLI commands and patterns. Use when working with healthsync CLI, fetching Apple Health data (steps, heart rate, sleep, workouts), pairing iOS devices over local network, or understanding the iOS Health Sync project architecture including mTLS certificate pinning, Keychain storage, and audit logging.
iOS HealthKit 数据同步 CLI 命令和模式。用于 healthsync CLI 获取 Apple Health 数据(步数、心率、睡眠、锻炼),本地网络配对 iOS 设备,或了解 iOS Health Sync 架构(包括 mTLS 证书固定、Keychain 存储、审计日志)。
mneves75
开发者工具 clawhub v1.0.0 1 版本 99120.4 Key: 无需
★ 12
Stars
📥 4,155
下载
💾 387
安装
1
版本
#health#healthkit#ios#latest#macos

概述

HealthKit Sync CLI

Securely sync Apple HealthKit data from iPhone to Mac over local network using mTLS.

When to Use This Skill

  • User asks about syncing health data from iPhone
  • User mentions healthsync CLI commands
  • User wants to fetch steps, heart rate, sleep, or workout data
  • User needs to pair a Mac with an iOS device
  • User asks about the iOS Health Sync project architecture
  • User mentions certificate pinning or mTLS patterns

CLI Quick Reference

Pairing Flow (First Time)

# 1. Discover devices on local network
healthsync discover

# 2. On iOS app: tap "Share" to generate QR code, then "Copy"
# 3. Scan QR from clipboard (Universal Clipboard)
healthsync scan

# Alternative: scan from image file
healthsync scan --file ~/Desktop/qr.png

Fetching Health Data

# Check connection status
healthsync status

# List enabled data types
healthsync types

# Fetch data as CSV (default)
healthsync fetch --start 2026-01-01T00:00:00Z --end 2026-12-31T23:59:59Z --types steps

# Fetch multiple types as JSON
healthsync fetch --start 2026-01-01T00:00:00Z --end 2026-12-31T23:59:59Z \
  --types steps,heartRate,sleepAnalysis --format json | jq

# Pipe to file
healthsync fetch --start 2026-01-01T00:00:00Z --end 2026-12-31T23:59:59Z \
  --types steps > steps.csv

Available Health Data Types

Activity: steps, distanceWalkingRunning, distanceCycling, activeEnergyBurned, basalEnergyBurned, exerciseTime, standHours, flightsClimbed, workouts

Heart: heartRate, restingHeartRate, walkingHeartRateAverage, heartRateVariability

Vitals: bloodPressureSystolic, bloodPressureDiastolic, bloodOxygen, respiratoryRate, bodyTemperature, vo2Max

Sleep: sleepAnalysis, sleepInBed, sleepAsleep, sleepAwake, sleepREM, sleepCore, sleepDeep

Body: weight, height, bodyMassIndex, bodyFatPercentage, leanBodyMass

Configuration

Config stored at ~/.healthsync/config.json (permissions: 0600):

{
  "host": "192.168.1.x",
  "port": 8443,
  "fingerprint": "sha256-certificate-fingerprint"
}

Token stored in macOS Keychain under service org.mvneves.healthsync.cli.

Security Architecture

Certificate Pinning

The CLI validates server certificates by SHA256 fingerprint (TOFU model):

  1. First pairing stores fingerprint from QR code
  2. Subsequent connections verify fingerprint matches
  3. Mismatch = connection rejected (MITM protection)

Local Network Only

Host validation restricts connections to:

  • localhost, *.local domains
  • Private IPv4: 192.168., 10., 172.16-31.*
  • IPv6 loopback: ::1, link-local: fe80::

Keychain Storage

Tokens never stored in config file - always in Keychain with:

  • kSecAttrAccessibleWhenUnlocked protection class
  • Service: org.mvneves.healthsync.cli
  • Account: token-{host}

Project Structure

ai-health-sync-ios-clawdbot/
├── iOS Health Sync App/          # Swift 6 iOS app
│   ├── Services/Security/        # CertificateService, KeychainStore, PairingService
│   ├── Services/HealthKit/       # HealthKitService, HealthSampleMapper
│   ├── Services/Network/         # NetworkServer (TLS), HTTPTypes
│   └── Services/Audit/           # AuditService (SwiftData)
└── macOS/HealthSyncCLI/          # Swift Package CLI

Troubleshooting

"No devices found":

  • Ensure iOS app is running with sharing enabled
  • Both devices must be on same Wi-Fi network
  • Check firewall isn't blocking mDNS (port 5353)

"Pairing code expired":

  • Generate new QR code on iOS app (codes expire in 5 minutes)

"Certificate mismatch":

  • Delete ~/.healthsync/config.json and re-pair
  • Server certificate may have been regenerated

"Connection refused":

  • iOS app server may not be running
  • Run healthsync status --dry-run to test without connecting

See Also

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-28 10:34 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 65 📥 179,842
developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 666 📥 323,791
data-analysis

Apple Mail Search

mneves75
在 macOS 上通过 SQLite 快速搜索 Apple Mail,支持主题、发件人、日期、附件,响应约 50ms(AppleScript 需 8+ 分钟)。当需要查找、搜索或列出邮件时使用。
★ 2 📥 3,732