Apple's framework for health and fitness data management. HealthKit provides a central repository for health and fitness data, allowing apps to share and access health information with user permission.
of iOS users worldwide can use HealthKit (iOS 8+ required)
| iOS Version | Market Share | Status |
|---|---|---|
| iOS 18.7 | 30.3% | Supported |
| iOS 18.6 | 29.8% | Supported |
| iOS 26.1 | 10.7% | Supported |
| iOS 18.5 | 6.0% | Supported |
| iOS 16.7 | 2.3% | Supported |
| iOS 26.2 | 2.0% | Supported |
| iOS 18.3 | 1.8% | Supported |
| iOS 15.8 | 1.8% | Supported |
| iOS 11.0 | 1.7% | Supported |
| iOS 17.6 | 1.7% | Supported |
Store and query health data
Share data between health apps
Background delivery of health updates
Workout and activity tracking
Heart rate and vital signs monitoring
Integration with Apple Watch
Request permission to read and write health data
import HealthKit
class HealthKitManager {
let healthStore = HKHealthStore()
func requestAuthorization() {
guard HKHealthStore.isHealthDataAvailable() else {
print("HealthKit not available")
return
}
let typesToRead: Set<HKObjectType> = [
HKObjectType.quantityType(forIdentifier: .stepCount)!,
HKObjectType.quantityType(forIdentifier: .heartRate)!
]
let typesToWrite: Set<HKSampleType> = [
HKObjectType.quantityType(forIdentifier: .stepCount)!
]
healthStore.requestAuthorization(toShare: typesToWrite, read: typesToRead) { success, error in
if success {
print("HealthKit authorized")
} else if let error = error {
print("Error: \(error.localizedDescription)")
}
}
}
}Retrieve step count data for today
import HealthKit
func queryStepCount(completion: @escaping (Double) -> Void) {
guard let stepType = HKQuantityType.quantityType(forIdentifier: .stepCount) else { return }
let now = Date()
let startOfDay = Calendar.current.startOfDay(for: now)
let predicate = HKQuery.predicateForSamples(withStart: startOfDay, end: now, options: .strictStartDate)
let query = HKStatisticsQuery(quantityType: stepType, quantitySamplePredicate: predicate, options: .cumulativeSum) { _, result, error in
guard let result = result, let sum = result.sumQuantity() else {
completion(0)
return
}
completion(sum.doubleValue(for: HKUnit.count()))
}
HKHealthStore().execute(query)
}Apple's framework for health and fitness data management. HealthKit provides a central repository for health and fitness data, allowing apps to share and access health information with user permission.
HealthKit is available on iOS 8 and later. Currently, 99.7% of iOS users worldwide can use this framework.
Related frameworks include Coremotion. Each has different capabilities and iOS version requirements.