Registry / serialization / pyobjc-framework-healthkit

pyobjc-framework-healthkit

JSON →
library12.2pypypiunverified

PyObjC-framework-HealthKit provides Python bindings for Apple's HealthKit framework on macOS. It allows Python applications to interact with health and fitness data, offering a bridge to Objective-C APIs. The library is actively maintained with frequent releases, often synchronized with macOS SDK updates and changes in Python version support.

pip install pyobjc-framework-healthkit
INSTALL
IMPORT
SIG · PYOBJC-FRAMEWORK-H
P
pyobjc-framework-healthkit
serializationpythonv12.2
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
build_error
glibc
py 3.103.920 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

HealthKit
import HealthKit
HKHealthStore
from HealthKit import HKHealthStore
HKObjectType
from HealthKit import HKObjectType

This quickstart demonstrates how to check for HealthKit availability and request authorization to read specific data types (Body Mass and Height). Running this code will trigger a system prompt asking the user for permission. HealthKit operations require an active run loop to handle asynchronous callbacks. For a standalone script, `PyObjCTools.AppHelper.runEventLoop()` is essential to process these callbacks and wait for the authorization request to complete. Note that HealthKit features require an application with the proper entitlements set in Xcode.

import HealthKit from PyObjCTools import AppHelper def request_health_authorization(): if not HealthKit.HKHealthStore.isHealthDataAvailable(): print("HealthKit is not available on this device.") return health_store = HealthKit.HKHealthStore.alloc().init() # Define types to read and write # Example: Body Mass and Height try: body_mass_type = HealthKit.HKObjectType.quantityTypeForIdentifier_( HealthKit.HKQuantityTypeIdentifierBodyMass ) height_type = HealthKit.HKObjectType.quantityTypeForIdentifier_( HealthKit.HKQuantityTypeIdentifierHeight ) except Exception as e: print(f"Error getting HealthKit object types: {e}") return types_to_read = {body_mass_type, height_type} types_to_share = set() # No data to write in this example # Request authorization # Note: This will trigger a system prompt to the user def completion_handler(success, error): if success: print("HealthKit authorization granted.") # You can now proceed with HealthKit operations else: print(f"HealthKit authorization denied or error: {error}") AppHelper.stopEventLoop() health_store.requestAuthorizationToShareTypes_readTypes_completion_( types_to_share, types_to_read, completion_handler ) if __name__ == '__main__': # Run this from a macOS app context or a script with UI entitlements # For a simple script, ensure PyObjCTools.AppHelper.runEventLoop() is used # to handle asynchronous callbacks. print("Requesting HealthKit authorization...") request_health_authorization() # For simple scripts where a UI application loop isn't explicitly started, # AppHelper.runEventLoop() ensures callbacks are processed. # In a full Cocoa app, the app's runloop would handle this. AppHelper.runEventLoop()
Debug
Known issues
breakingPyObjC drops support for older Python versions with major releases. Python 3.9 support was dropped in PyObjC v12.0, and Python 3.8 support was dropped in v11.0. Ensure your Python environment meets the `requires_python` spec (currently `>=3.10`).
fix
Upgrade Python to a supported version (e.g., 3.10+ for PyObjC 12.x).
affects: >=11.0
breakingPyObjC v11.1 aligned its behavior for initializer methods with `clang`'s Automatic Reference Counting (ARC) documentation. Methods in the 'init' family now correctly steal a reference to `self` and return a new reference. This change can impact custom Objective-C `init` method wrappers if not handled correctly.
fix
Review custom `init` method implementations and their Python wrappers, especially regarding reference counting, to ensure compatibility with ARC semantics.
affects: >=11.1
gotchaHealthKit functionality requires specific entitlements (`HealthKit` capability) and privacy descriptions (`Privacy - Health Share Usage Description`, `Privacy - Health Update Usage Description`) added to your application's `Info.plist` file within Xcode. Without these, authorization requests will fail or the framework will be unavailable.
fix
Configure your macOS application's Xcode project to include the HealthKit capability and add the necessary privacy usage descriptions to its `Info.plist` file.
affects: all
gotchaPyObjC does not support the experimental free-threading (PEP 703) feature introduced in Python 3.13. While binary wheels might be available for Python 3.13, using free-threading with PyObjC can lead to instability or incorrect behavior.
fix
Avoid using Python's experimental free-threading (`python -X 'gil=0'`) when developing applications that rely on PyObjC frameworks. Use standard Python threading if needed.
affects: >=10.3
gotchaHealthKit is not universally available on all macOS devices or operating system versions (e.g., it might not be available on older macOS versions or specific hardware configurations). Always check `HKHealthStore.isHealthDataAvailable()` before attempting any HealthKit operations.
fix
Wrap all HealthKit-dependent code paths with a check for `HealthKit.HKHealthStore.isHealthDataAvailable()` to gracefully handle environments where HealthKit is not present.
affects: all
Upgrade
Version history
12.2latest on PyPI · released May 30, 2026
Audit
Dependencies
pyobjc-corerequiredCore bridge between Python and Objective-C, required for all PyObjC framework wrappers.
Agent activity
6 hits · last 30 days
node
6
Resources
pyobjc-framework-healthkit — pip install pyobjc-framework-healthkit · libregistry