axiom-health

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

HealthKit and WorkoutKit

HealthKit and WorkoutKit

You MUST use this skill for ANY HealthKit or WorkoutKit development including authorization, data queries, background delivery, workout sessions, planned workouts, wellbeing APIs (State of Mind), Medications, and Health Records.
任何涉及HealthKit或WorkoutKit的开发工作都必须使用本技能,包括授权、数据查询、后台推送、健身会话、计划健身活动、健康状态API(State of Mind)、药物管理以及健康记录等内容。

Quick Reference

快速参考

Symptom / TaskReference
HealthKit framework model,
HKHealthStore
, data types, sample vs characteristic data
See
skills/fundamentals.md
Capability setup,
requestAuthorization
, purpose strings, read-asymmetry, privacy
See
skills/authorization-and-privacy.md
HKSampleQuery
, Swift Concurrency query APIs,
HKStatisticsCollectionQuery
, sample writes
See
skills/queries.md
Anchored queries, observer queries,
HKDeletedObject
,
background-delivery
entitlement
See
skills/sync-and-background.md
HKWorkoutSession
,
HKLiveWorkoutBuilder
, recovery, multi-device, iOS/iPadOS/watchOS workout tracking
See
skills/workouts.md
WorkoutKit custom/planned workouts, scheduling, swimming workouts, previewingSee
skills/workoutkit.md
State of Mind, Medications API, symptom logging, wellbeing APIsSee
skills/wellbeing-and-medications.md
Health Records (FHIR), Mobility Health App, motion-based healthSee
skills/clinical-and-mobility.md
场景/任务参考文档
HealthKit框架模型、
HKHealthStore
、数据类型、样本数据与特征数据
查看
skills/fundamentals.md
功能配置、
requestAuthorization
、用途说明字符串、读取权限不对称性、隐私保护
查看
skills/authorization-and-privacy.md
HKSampleQuery
、Swift并发查询API、
HKStatisticsCollectionQuery
、样本数据写入
查看
skills/queries.md
锚定查询、观察者查询、
HKDeletedObject
background-delivery
权限
查看
skills/sync-and-background.md
HKWorkoutSession
HKLiveWorkoutBuilder
、恢复功能、多设备支持、iOS/iPadOS/watchOS健身追踪
查看
skills/workouts.md
WorkoutKit自定义/计划健身活动、日程安排、游泳健身活动、预览功能查看
skills/workoutkit.md
State of Mind、药物API、症状记录、健康状态API查看
skills/wellbeing-and-medications.md
健康记录(FHIR)、移动健康应用、基于运动的健康功能查看
skills/clinical-and-mobility.md

Cross-Suite Routes

跨套件指引

These topics overlap with HealthKit/WorkoutKit but live in separate suites:
以下主题与HealthKit/WorkoutKit相关,但属于其他独立套件:

watchOS presentation

watchOS 展示相关

  • Watch-specific workout presentation (Always On, Smart Stack), complication surfaces → See axiom-watchos
  • Workout app structure on Apple Watch → See axiom-watchos (
    skills/platform-basics.md
    )
  • Apple Watch专属健身活动展示(常亮显示、智能堆叠)、复杂功能界面 → 查看 axiom-watchos
  • Apple Watch上的健身应用结构 → 查看 axiom-watchos(
    skills/platform-basics.md

Concurrency

并发编程

  • Swift 6 concurrency, actors, Sendable → See axiom-concurrency
  • HealthKit queries bridging to Swift Concurrency →
    skills/queries.md
    is the canonical example
  • Swift 6并发、actor、Sendable → 查看 axiom-concurrency
  • HealthKit查询与Swift并发的适配 →
    skills/queries.md
    是标准示例

SwiftUI

SwiftUI

  • Charts rendering for health data → See axiom-swiftui
  • @Observable
    view models for health data → See axiom-swiftui
  • 健康数据图表渲染 → 查看 axiom-swiftui
  • 健康数据的
    @Observable
    视图模型 → 查看 axiom-swiftui

Data and sync

数据与同步

  • General cross-platform sync patterns (CloudKit, GRDB) → See axiom-data
  • HealthKit anchored/observer queries as a generalizable sync mechanism →
    skills/sync-and-background.md
  • 通用跨平台同步模式(CloudKit、GRDB)→ 查看 axiom-data
  • HealthKit锚定/观察者查询作为通用同步机制 →
    skills/sync-and-background.md

Security and privacy

安全与隐私

  • Keychain storage, encryption, data-protection entitlements → See axiom-security
  • Keychain存储、加密、数据保护权限 → 查看 axiom-security

Conflict Resolution

冲突解决

axiom-health vs axiom-watchos: For workout apps on Apple Watch:
  1. Use axiom-health for
    HKWorkoutSession
    lifecycle,
    HKLiveWorkoutBuilder
    , recovery APIs, multi-device mirroring — these are HealthKit concepts, not watch concepts
  2. Use axiom-watchos for watch-specific presentation: Always On display, Smart Stack placement, watchOS background mode coordination
  3. Both apply for a watch-native workout app — start with axiom-health for session lifecycle, then axiom-watchos for presentation
axiom-health vs axiom-concurrency: For HealthKit query patterns:
  1. Use axiom-health for which query type to choose and HealthKit-specific gotchas
  2. Use axiom-concurrency for general Swift 6 actor isolation rules that apply to query callbacks
axiom-health vs axiom-data: For change-tracked data synchronization:
  1. Use axiom-health for
    HKAnchoredObjectQuery
    ,
    HKObserverQuery
    ,
    HKDeletedObject
  2. Use axiom-data for application-level data sync across devices (CloudKit, GRDB, SwiftData)
axiom-health vs axiom-watchos:针对Apple Watch上的健身应用:
  1. 使用axiom-health处理
    HKWorkoutSession
    生命周期、
    HKLiveWorkoutBuilder
    、恢复API、多设备镜像 —— 这些属于HealthKit概念,而非watch专属概念
  2. 使用axiom-watchos处理watch专属展示:常亮显示、智能堆叠布局、watchOS后台模式协同
  3. 两者均适用于watch原生健身应用 —— 先使用axiom-health处理会话生命周期,再使用axiom-watchos处理展示逻辑
axiom-health vs axiom-concurrency:针对HealthKit查询模式:
  1. 使用axiom-health选择查询类型以及了解HealthKit专属注意事项
  2. 使用axiom-concurrency处理适用于查询回调的通用Swift 6 actor隔离规则
axiom-health vs axiom-data:针对变更追踪的数据同步:
  1. 使用axiom-health处理
    HKAnchoredObjectQuery
    HKObserverQuery
    HKDeletedObject
  2. 使用axiom-data处理跨设备的应用级数据同步(CloudKit、GRDB、SwiftData)

Decision Tree

决策树

dot
digraph health {
    start [label="HealthKit / workout task" shape=ellipse];
    what [label="What area?" shape=diamond];

    start -> what;
    what -> "skills/fundamentals.md" [label="framework basics, data types"];
    what -> "skills/authorization-and-privacy.md" [label="permissions, purpose strings, privacy"];
    what -> "skills/queries.md" [label="reading data, rollups, writes"];
    what -> "skills/sync-and-background.md" [label="change tracking, background delivery"];
    what -> "skills/workouts.md" [label="HKWorkoutSession, live workouts"];
    what -> "skills/workoutkit.md" [label="planned/custom workouts"];
    what -> "skills/wellbeing-and-medications.md" [label="State of Mind, Medications"];
    what -> "skills/clinical-and-mobility.md" [label="Health Records, Mobility"];
    what -> "axiom-watchos" [label="watch-specific presentation"];
    what -> "axiom-concurrency" [label="general actor isolation rules"];
    what -> "axiom-swiftui" [label="Charts, data visualization"];
}
dot
digraph health {
    start [label="HealthKit / workout task" shape=ellipse];
    what [label="What area?" shape=diamond];

    start -> what;
    what -> "skills/fundamentals.md" [label="framework basics, data types"];
    what -> "skills/authorization-and-privacy.md" [label="permissions, purpose strings, privacy"];
    what -> "skills/queries.md" [label="reading data, rollups, writes"];
    what -> "skills/sync-and-background.md" [label="change tracking, background delivery"];
    what -> "skills/workouts.md" [label="HKWorkoutSession, live workouts"];
    what -> "skills/workoutkit.md" [label="planned/custom workouts"];
    what -> "skills/wellbeing-and-medications.md" [label="State of Mind, Medications"];
    what -> "skills/clinical-and-mobility.md" [label="Health Records, Mobility"];
    what -> "axiom-watchos" [label="watch-specific presentation"];
    what -> "axiom-concurrency" [label="general actor isolation rules"];
    what -> "axiom-swiftui" [label="Charts, data visualization"];
}

Resources

资源

WWDC: 2019-218, 2020-10182, 2020-10184, 2020-10664, 2021-10009, 2021-10287, 2022-10005, 2023-10016, 2023-10023, 2024-10084, 2024-10109, 2025-321, 2025-322
Docs: /healthkit, /healthkit/about-the-healthkit-framework, /healthkit/authorizing-access-to-health-data, /healthkit/protecting-user-privacy, /healthkit/reading-data-from-healthkit, /healthkit/running-queries-with-swift-concurrency, /healthkit/executing-anchored-object-queries, /healthkit/executing-observer-queries, /healthkit/hkworkoutsession, /healthkit/hklivewobuilder, /workoutkit, /healthkit/accessing-health-records
Skills: axiom-watchos, axiom-concurrency, axiom-swiftui, axiom-data, axiom-security
WWDC: 2019-218, 2020-10182, 2020-10184, 2020-10664, 2021-10009, 2021-10287, 2022-10005, 2023-10016, 2023-10023, 2024-10084, 2024-10109, 2025-321, 2025-322
文档: /healthkit, /healthkit/about-the-healthkit-framework, /healthkit/authorizing-access-to-health-data, /healthkit/protecting-user-privacy, /healthkit/reading-data-from-healthkit, /healthkit/running-queries-with-swift-concurrency, /healthkit/executing-anchored-object-queries, /healthkit/executing-observer-queries, /healthkit/hkworkoutsession, /healthkit/hklivewobuilder, /workoutkit, /healthkit/accessing-health-records
技能: axiom-watchos, axiom-concurrency, axiom-swiftui, axiom-data, axiom-security