healthkit
Read, write, and query Apple Health data using HealthKit. Covers HKHealthStore authorization, sample queries, statistics queries, statistics collection queries for charts, saving HKQuantitySample data, background delivery, workout sessions with HKWorkoutSession and HKLiveWorkoutBuilder, HKUnit, and HKQuantityTypeIdentifier values. Use when integrating with Apple Health, displaying health metrics, recording workouts, or enabling background health data delivery.
Security Assessment
Detected risks:
About healthkit
The HealthKit skill enables developers to integrate Apple Health data into their iOS, watchOS, and visionOS applications. It provides comprehensive access to reading, writing, and querying health and fitness data stored in the Apple Health store, including authorization management, sample queries, statistics queries, and real-time workout session tracking. This skill is essential for building health and fitness applications that need to interact with the user's health data while respecting privacy and platform requirements.
The skill covers core HealthKit functionality including HKHealthStore authorization flows, multiple query types for retrieving data (sample queries, statistics queries, and statistics collection queries for visualizations), writing HKQuantitySample data to the Health store, background delivery for passive data monitoring, and workout sessions using HKWorkoutSession and HKLiveWorkoutBuilder. It includes detailed reference information for HKUnit conversions and HKQuantityTypeIdentifier values, ensuring developers can work with various health metrics accurately.
This skill targets developers building health and fitness applications on Swift 6.3 and iOS 26+, including workout tracking apps, health dashboards, fitness challenges, medical monitoring tools, and wellness applications. It helps developers navigate HealthKit's authorization requirements, implement efficient data queries, display health metrics and charts, record workout sessions with live updates, and enable background health data delivery for continuous monitoring scenarios.
FAQ
What iOS versions and platforms does this HealthKit skill support?
This skill targets Swift 6.3 and iOS 26+. HealthKit is available on iOS, watchOS, visionOS, and iPadOS 17+. Note that Health data is unavailable on iPadOS 16 or earlier and may be restricted by managed device policies. Always check availability using HKHealthStore.isHealthDataAvailable() before using HealthKit APIs.
How do I request authorization to access health data?
You must request authorization by specifying the exact data types you need to read and write using the requestAuthorization method. Only request types your app genuinely needs, as App Review rejects apps that over-request permissions. You need to add NSHealthShareUsageDescription and NSHealthUpdateUsageDescription to your Info.plist and enable the HealthKit capability in Xcode.
Can I tell if a user denied read access to health data?
No. HealthKit does not reveal whether read permission was granted or denied for privacy reasons. If the user denies read access, queries will only return samples your app successfully saved, which may appear as empty or partial data. You can only check authorization status for write/share permissions using authorizationStatus(for:).
What query types are available for reading health data?
HealthKit provides three main query types: Sample Queries (HKSampleQueryDescriptor) for one-shot reads of individual samples, Statistics Queries for aggregated data like sums and averages over a time period, and Statistics Collection Queries for time-series data used in charts and visualizations. The skill recommends using async/await descriptors over older callback-based queries.
How do I enable background delivery for continuous health monitoring?
Enable the 'Background Delivery' sub-capability in your HealthKit capability settings, create a single HKHealthStore instance, and use background delivery APIs to register for updates when specific health data types change. This allows your app to receive notifications and process health data even when not actively running.
Install healthkit
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
dpearson2699/swift-ios-skills