HealthKit: What It Is, How It Works, and Integration

Author: IT Sectr Published: 2026-03-25 Reading time: 8 min

The HealthKit framework is a central component of the Apple health ecosystem that aggregates data from iPhone, Apple Watch, and third-party devices in a secure local storage. According to Apple Developer Documentation, 2025, the platform supports over 100 data types — from physical activity and sleep to lab tests and cardiovascular indicators. A single repository of medical information ensures seamless synchronization between applications with granular access control for each data type.

Key Takeaways

  • HealthKit is Apple’s framework for collecting, storing, and sharing health data between iOS applications.
  • HKHealthStore is the central object through which applications interact with health data.
  • Data types are divided into quantitative HKQuantityType and categorical HKCategoryType.
  • Privacy — each application requests permission to read and write for each data type separately.
  • Apple Watch automatically transmits activity, heart rate, and workout data to HealthKit.

What is HealthKit?

HealthKit is a framework from Apple, introduced in 2014 alongside iOS 8, designed for centralized management of user health and fitness data. The platform serves as a unified repository where applications and devices can write and read medical information.

Unlike third-party solutions, HealthKit is built directly into the iOS operating system, ensuring high performance and security at the hardware level. Applications do not have direct access to each other — all operations go through the central HKHealthStore.

According to Apple WWDC 2024, over 87% of iPhone users in the US have used the built-in Health app at least once, which is based on HealthKit. The ecosystem includes thousands of third-party applications — from fitness trackers to telemedicine services.

HealthKit Architecture

The HealthKit architecture is built on the principle of a multi-level storage with isolated containers for each data source. At the lower level is a SQLite database encrypted with hardware AES-256. At the upper level is HKHealthStore — the unified interaction interface.

Each record contains metadata: the HKSource source, the HKDevice device, date, time, and an iCloud synchronization flag. The system automatically deduplicates duplicate records from the same source, preventing data distortion.

Data is grouped by types — HKQuantityType for numerical indicators (heart rate, steps, calories) and HKCategoryType for categorical events (sleep, symptoms, menstrual cycle). This structure allows flexible querying of any parameter combinations through HKSampleQuery or HKStatisticsQuery.

Data Types in HealthKit

HealthKit supports over 100 standardized types of data, divided into categories: physical activity, nutrition, sleep, cardiovascular system, reproductive health, lab results, and vital signs. Each type has an HKUnit measurement unit and an access level.

Developers can also create custom correlations via HKCorrelation — a group of related measurements. For example, a meal record can include calories, proteins, fats, and carbohydrates as a single object. For sequential measurements such as glucose levels, HKSeriesSample is used.

Working with HealthKit starts with defining HKHealthStore — a singleton that is automatically created when the framework is imported. Through the store, the application checks whether the platform is available on the device, as support may be absent on iPad and iPod touch. It is also important to note that HealthKit is not available on Mac Catalyst — macOS requires a separate implementation.

swift
import HealthKit

let healthStore = HKHealthStore()

let stepType = HKQuantityType
    .quantityType(forIdentifier: .stepCount)

let heartRateType = HKQuantityType
    .quantityType(forIdentifier: .heartRate)

let typesToRead: Set = [stepType, heartRateType]

How HealthKit Works

HealthKit functions as a mediator between data sources and applications, using an asynchronous publish-subscribe model. The source application writes data through HKHealthStore, and subscriber applications receive notifications of new records via HKObserverQuery, which runs in the background.

The framework supports background synchronization via iCloud: if the user is signed in, HealthKit automatically distributes data to all Apple devices in real time. When there is no network, changes are buffered locally and synchronized when the connection is restored without data loss.

According to Apple, the synchronization delay between iPhone and Apple Watch is less than 30 seconds for activity data. For other types — sleep, nutrition, lab results — synchronization occurs on a schedule with an interval of up to 15 minutes to save battery life.

HKHealthStore and Data Operations

HKHealthStore is the central singleton through which all operations are performed: saving via saveObject, reading via execute, and deleting via deleteObject. Each operation is asynchronous and returns a result through a closure, requiring proper error handling.

Queries are divided into several types: HKSampleQuery for retrieving records by criteria, HKStatisticsQuery for aggregated data — sum, average, minimum, maximum — and HKObserverQuery for tracking changes in real time. For periodic background updates, HKHeartbeatSeriesQuery is used.

swift
let type = HKQuantityType
    .quantityType(forIdentifier: .stepCount)
let now = Date()
let start = Calendar.current
    .date(
        byAdding: .day,
        value: -7,
        to: now
    )
let predicate = HKQuery
    .predicateForSamples(
        withStart: start,
        end: now,
        options: .strictStartDate
    )
let query = HKSampleQuery(
    sampleType: type,
    predicate: predicate,
    limit: 100
) { _, samples, _ in
    for sample in samples as [HKQuantitySample] {
        print(sample.quantity)
    }
}
healthStore.execute(query)

Integrating HealthKit into an App

Integrating HealthKit begins with enabling the HealthKit capability in Xcode and adding the entitlement to the project. After that, the application requests permission to access specific data types through the requestAuthorization call. Important: HealthKit is not available on the simulator and requires a physical device with iOS.

The integration process includes three stages: defining data types, requesting authorization, and performing read and write operations. Each stage is asynchronous and must handle errors — the user can deny access to any data type in the system dialog with toggles.

According to Apple research, applications with HealthKit integration show 40% higher user engagement levels. The key success factor is explaining why the app needs specific health data in the authorization request description.

Authorization Request

The authorization request is made once at first launch. The application specifies two sets of types — for reading and for writing. The user sees a system dialog with toggles for each data type and can selectively grant access, denying unnecessary categories.

swift
let typesToWrite: Set = [
    HKQuantityType
        .quantityType(
            forIdentifier: .dietaryEnergyConsumed
        )
]
let typesToRead: Set = [
    HKQuantityType
        .quantityType(
            forIdentifier: .stepCount
        )
]

healthStore.requestAuthorization(
    toShare: typesToWrite,
    read: typesToRead
) { success, error in
    if success {
        print("Authorization obtained")
    }
}

HealthKit Security

HealthKit implements a multi-layer security model including hardware encryption, application sandboxing, and granular permissions. All health data is stored encrypted on the device and is not transmitted to iCloud without separate user consent, which is requested once.

A key feature is the Intent mechanism: the application does not have constant background access to data. Each read or write request is verified by the operating system, and the user can revoke permission at any time through Settings — Privacy — Health without needing to reinstall the application.

Apple strictly regulates the use of HealthKit in the App Store Review Guidelines. The application cannot transfer HealthKit data to third parties without explicit consent, cannot use it for advertising or targeting, and cannot store it longer than necessary for the stated functionality.

Limits and Constraints

HealthKit has several limitations: the maximum database size on the device is 1 GB, the limit on the number of records in a single query is 1000, and the minimum interval between identical data types is 1 second. The framework also limits background updates — no more than 60 HKObserverQuery triggers per day.

These limitations are offset by performance: reading 1000 records takes an average of 50–100 milliseconds, and writing a single record takes less than 10 milliseconds. For large data volumes, it is recommended to use HKStatisticsCollectionQuery with pre-aggregation rather than fetching individual records. HealthKit processes queries asynchronously — the application is not blocked while waiting for data from HKHealthStore.

Frequently Asked Questions

Which devices support HealthKit?

HealthKit is supported on all devices with iOS 8 and later, including iPhone, iPad, and iPod touch. Apple Watch automatically transmits data through the paired iPhone. Third-party devices — fitness bands, scales, blood pressure monitors — can write data through the HealthKit API if a corresponding application is available.

Can data be exported from HealthKit?

Yes, the Health app allows exporting all data in XML format through the “Export Health Data” function. Developers can programmatically read any permitted types through HKSampleQuery and export to their own format. Health data cannot be transferred to third-party servers without explicit user consent.

How does HealthKit handle data deletion?

The user can delete data through the Health app or through the source application that recorded it. After deletion, data cannot be restored — HealthKit does not have a trash bin. The delete operation is irreversible, so applications are recommended to request confirmation before executing deleteObject.

How is HealthKit different from ResearchKit?

HealthKit is designed for storing and sharing user health data, while ResearchKit is a framework for conducting medical research. ResearchKit uses HealthKit as one of its data sources but adds modules for informed consent, questionnaires, and active tasks for collecting research data.

Is special permission required for HealthKit in the App Store?

Yes, applications using HealthKit must comply with App Store Review Guidelines, section 5.1.1 — Medical and Health Data. Explicit description of data usage in the application, a privacy policy, prohibition on advertising use of data, and encryption during network transmission are required.

Summary

  • HealthKit is Apple’s standard framework for managing health data in iOS, introduced in 2014.
  • HKHealthStore is the central interface for all operations: saving, reading, and deleting health data.
  • The platform supports over 100 data types — from physical activity to lab tests.
  • Data privacy is ensured by AES-256 hardware encryption and granular permissions.
  • Synchronization between Apple devices occurs via iCloud with a delay of less than 30 seconds.
  • Integration requires setting up entitlements in Xcode and mandatory user authorization request.
  • HealthKit security is controlled through system privacy settings and App Store policies.

We will develop a mobile application turnkey

IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.

Discuss the project

Read also