HealthKit

RSS for tag

Access and share health and fitness data while maintaining the user’s privacy and control using HealthKit.

Posts under HealthKit tag

98 Posts

Post

Replies

Boosts

Views

Activity

Bug apple Health
Hello everyone, I’m experiencing a visual issue when dismissing a sheet on iOS 26. I’m using the same implementation shown in the official Apple documentation. While testing, I noticed that some apps do not exhibit this behavior. However, when running this code on iOS 26, the issue consistently occurs. Issue description: The sheet dismisses abruptly A white screen briefly appears for a few milliseconds and then disappears This results in a noticeable visual glitch and a poor user experience I tested the exact same code on iOS 18, where the sheet dismisses smoothly and behaves as expected, without any visual artifacts. Has anyone else encountered this issue on iOS 26? Is this a known bug, or is there a recommended workaround? Any insights would be greatly appreciated. Thank you.
2
0
150
1d
How to detect when Apple Watch is removed from wrist during active workout session?
I'm currently collecting real-time heart rate data using HKWorkoutSession. I want to track when the Apple Watch is physically removed from the user's wrist during an active workout. However, I've noticed that workoutBuilder(_:didCollectDataOf:) continues to be called even after the watch is removed from the wrist. Is there a way to detect when the Apple Watch is removed from the wrist during an active HKWorkoutSession? Or is this tracking not possible through the HealthKit framework? Any guidance or alternative approaches would be appreciated.
0
0
19
2d
Is it possible to distinguish real vs manually added running data in HealthKit?
I am developing an iOS application that utilizes running workout data from the iOS Health app / Fitness app via HealthKit, with explicit user permission. Before finalizing the app design, I would like to clarify several technical aspects related to data reliability, manual entry, record modification, and GPS route availability in HealthKit. My questions are as follows: 1. Identifying manually added (non-physical) running workouts When a running workout is created in the Health app without actual physical movement (for example, a workout manually added by the user), is there any metadata, flag, or key in HealthKit that allows developers to distinguish these records from workouts generated through actual motion tracking (iPhone or Apple Watch)? 2. Editing existing running workout records Is it possible for users, or for third-party apps with HealthKit write permission, to edit an existing running workout (e.g., distance, duration, calories) after it has been saved? • If edits are allowed, are the original values preserved in any way, or are they fully overwritten? 3. Detecting modified workout records If a running workout (whether originally auto-recorded or manually created) has been edited after creation, is there any identifier, metadata field, source revision, or versioning mechanism in HealthKit that allows developers to detect that the workout has been modified? 4. Access to GPS route / running path data For outdoor running workouts recorded with location services enabled: • Does HealthKit provide access to GPS route data (running paths / location traces) associated with a workout? • Is this route data accessible to third-party apps with user permission? • Is route data available only for workouts recorded on Apple Watch, or also for iPhone-only recordings? • Is there a way to determine programmatically whether a running workout includes valid GPS route data? The overall goal is to understand whether, when building an app that relies on HealthKit running data, it is technically possible to differentiate motion-based workouts from manually added or edited records, and to assess the availability of route information for outdoor runs. Any clarification or references to official documentation would be greatly appreciated. Thank you
1
0
36
1w
How to monitor heart rate in background without affecting Activity Rings?
I'm developing a watchOS nap app that detects when the user falls asleep by monitoring heart rate changes. == Technical Implementation == HKWorkoutSession (.mindAndBody) for background execution HKAnchoredObjectQuery for real-time heart rate data CoreMotion for movement detection == Battery Considerations == Heart rate monitoring ONLY active when user explicitly starts a session Monitoring continues until user is awakened OR 60-minute limit is reached If no sleep detected within 60 minutes, session auto-ends (user may have abandoned or forgotten to stop) App displays clear UI indicating monitoring is active Typical session: 15-30 minutes, keeping battery usage minimal == The Problem == HKWorkoutSession affects Activity Rings during the session. Users receive "Exercise goal reached" notifications while resting — confusing. == What I've Tried == Not using HKLiveWorkoutBuilder → Activity Rings still affected Using builder but not calling finishWorkout() (per https://developer.apple.com/forums/thread/780220) → Activity Rings still affected WKExtendedRuntimeSession (self-care type) (per https://developer.apple.com/forums/thread/721077) → Only ~10 min runtime, need up to 60 min HKObserverQuery + enableBackgroundDelivery (per https://developer.apple.com/forums/thread/779101) → ~4 updates/hour, too slow for real-time detection Audio background session for continuous processing (suggested in https://developer.apple.com/forums/thread/130287) → Concerned about App Store rejection for non-audio app; if official approves this technical route, I can implement in this direction Some online resources mention "Health Monitoring Entitlement" from WWDC 2019 Session 251, but I could not find any official documentation for this entitlement. Apple Developer Support also confirmed they cannot locate it? == My Question == Is there any supported way to: Monitor heart rate in background for up to 60 minutes WITHOUT affecting Activity Rings or creating workout records? If this requires a special entitlement or API access, please advise on the application process. Or allow me to submit a code-level support request. Any guidance would be greatly appreciated. Thank you!
0
0
44
1w
Can 3 party apps obtain Intervals information created using WorkoutKit?
I am developing a running training app that coaches can use to create interval workout plans. I can use HKWorkout to get information about Splits similar to that in Fitness app, but I can't get information about Intervals. My idea is to show interval details when users view their completed custom interval workout plans. Can I use Healthkit (or another feasible method) to get the actual distance or time of exercise in intervals workout ? (I know the workoutPlan property, but it doesn't reflect the segments of a real interval training workout.) Any insights or suggestions would be greatly appreciated! Thanks in advance!
0
0
100
3w
HKLiveWorkoutBuilder begincollection freezes in WatchOS simulator
The second time i start a workout session, the beginCollection instance method on HKLiveWorkoutBuilder freezes. To recreate run the Apple Sample Project Building a multidevice workout app. It looks like a bug with the HealthKit SDK and not the code but i could be wrong. The only workaround i found was erasing the simulator and reinstalling the app.
2
0
61
4w
HKLiveWorkoutBuilder begincollection freezes in sim
When calling beginCollection on HKLiveWorkoutBuilder the function never completes and gets stuck. (On the second workout session, the first session works flawlessly) To reproduce: Run the MirroringWorkoutsSample on WatchOS https://developer.apple.com/documentation/healthkit/building-a-multidevice-workout-app. Start the workout and then end the workouts it should work perfectly fine the first time. Start the workout and end again, and you should see the problem, the workout doesn’t end.
0
0
53
4w
Using HealthKit to display data on CarPlay UI
I'd like to investigate creating a safety feature for Type 1 Diabetics driving a car. Allowing HealthKit glucose data (read from a Dexcom G7 or similar) to be displayed as part of the CarPlay UI background or show an icon/button with the number visible. I'd also like to include a warning system for glucose low's that alerts the driver audibly. Has anyone looked into that before?
4
0
364
4w
Apple Watch stuck on "Copying shared cache symbols" – blocks real-time testing via Xcode
Hi everyone, I’m a student developer currently building a watchOS app that uses HealthKit and HKWorkoutSession to estimate core body temperature from real-time heart rate data. The app runs well in the simulator, but testing on a physical Apple Watch has been extremely difficult. Each time I try to run the app from Xcode (Version 16.3), the build gets stuck on: “Copying shared cache symbols from MyWatchName (0% completed)” Sometimes it just stops stating connection failure. However, more often no errors are shown, but the sync never finishes. I’ve tried the following without success: Restarting the watch, iPhone, and Xcode Switching networks (Wi-Fi and hotspot) USB wired pairing Resetting developer settings and trust prompts Deleting derived data Rebuilding the project This is especially limiting for a real-time health tracking app where I need to monitor HKLiveWorkoutBuilder data while the screen sleeps — which can’t be tested effectively in the simulator.
3
1
393
Nov ’25
WatchOS 26.1 - Steps Background delivery not working
I am using this below code since WatchOS 10 to set the user steps observer and get the callback of steps whenever changes. This is still working perfectly fine till watchOS 11 but when i updated to watchOS 26.1, I am not getting the callback of steps, like the observer is not working at all. I should get a callback inside query block whenever user take steps, but it is not working in watchOS 26.1. func setupStepCountObserver(completion: @escaping (Double, Double) -> Void) { let stepCountType = HKObjectType.quantityType(forIdentifier: .stepCount)! let query = HKObserverQuery(sampleType: stepCountType, predicate: nil) { [weak self] _, completionHandler, error in if let error = error { print("Error setting up observer query: \(error.localizedDescription)") return } // Fetch the latest step count data self?.getLast20SecTodaysSteps(completion: completion) // Call the completion handler to let HealthKit know you have processed the update completionHandler() } // Execute the query healthStore.execute(query) // Enable background delivery of updates healthStore.enableBackgroundDelivery(for: stepCountType, frequency: .immediate) { success, error in if let error = error { print("Error enabling background delivery steps: \(error.localizedDescription)") } else if success { print("Background delivery enabled for steps.") } } }
3
0
106
Nov ’25
Icon Composer - Icon not visible in Fitness App
Hi everyone, we’re developing an app that lets users export selected bike rides to the HealthKit ecosystem. We created our app icon using the Apple Icon Composer and referenced the composer file in Xcode. Everything works fine, except that the logo doesn’t appear correctly in the Fitness app. Has anyone experienced this issue or knows how to fix it?
2
1
153
Nov ’25
watchOS 26.0.2 / iOS 26.0.1 + Workout Session Mirroring Failure
Hi, I have a workout app in the App Store which mirrors workout data between the phone and watch. Since iOS 26.x I've been having issues and received reports of the mirroring no longer working. Users in iOS 18 have no problems with this functionality. Bug description: A workout session is started from the phone app and starts mirroring to the watch companion device. The watch starts the workout session and then the mirroring session is disconnected / lost. Sending data to the companion device fails and ending the session on the phone doesn't end the session on the watch...essentially they become completely disconnected. Please note I am testing this on physical devices...not simulators. As a sanity check I've also tried the "Building a multidevice workout app" sample code and it has the same problem. To re-create on the sample app, I start a workout from the phone, the watch workout starts and then the mirroring session seems to disconnect and is unable to send data. This is the log from the "Building a multidevice workout app" sample code. Successfully started workout Type: Notice | Timestamp: 2025-10-17 06:57:07.341401+02:00 | Process: MirroringWorkoutsSample Watch App | Library: MirroringWorkoutsSample Watch App.debug.dylib | Subsystem: com.example.apple-samplecode.MirroringWorkoutsSampleABC123.watchkitapp | Category: MirroringWorkoutsSampleForWatch | TID: 0x1b2ca7 -[SPRemoteInterface _appRecoverAnyExtendedRuntimeSession:]_block_invoke:4350: Got no sessions back from -[CSLSSessionService existingRunningSessions:] or -[CSLSSessionService existingScheduledSessions:] after receiving a PUICInitializeSessionServiceAction Type: Error | Timestamp: 2025-10-17 06:57:07.641571+02:00 | Process: MirroringWorkoutsSample Watch App | Library: WatchKit | Subsystem: com.apple.watchkit | Category: default | TID: 0x1b2ca7 Session state changed from 1 to 2 Type: Notice | Timestamp: 2025-10-17 06:57:07.647883+02:00 | Process: MirroringWorkoutsSample Watch App | Library: MirroringWorkoutsSample Watch App.debug.dylib | Subsystem: com.example.apple-samplecode.MirroringWorkoutsSampleABC123.watchkitapp | Category: MirroringWorkoutsSampleForWatch | TID: 0x1b2e87 Failed to send data: Error Domain=com.apple.healthkit Code=100 "Failed to send data to remote session." UserInfo={NSLocalizedDescription=Failed to send data to remote session.} Type: Notice | Timestamp: 2025-10-17 06:57:07.669922+02:00 | Process: MirroringWorkoutsSample Watch App | Library: MirroringWorkoutsSample Watch App.debug.dylib | Subsystem: com.example.apple-samplecode.MirroringWorkoutsSampleABC123.watchkitapp | Category: MirroringWorkoutsSampleForWatch | TID: 0x1b2ca7 Would appreciate any help with this problem as it's affecting customers. Thank you
10
1
503
Nov ’25
AirPods Pro 3 HRV Data Access Through HealthKit?
Hey everyone I'm working on a health app that's heavily focused on HRV tracking and analysis, and I'm trying to figure out what's actually possible with AirPods Pro 3 from a developer standpoint. The hardware clearly has a much better heart rate sensor than the previous generation, but I'm hitting some walls when it comes to actually accessing the data I need. So here's the situation I'm dealing with: When I query HealthKit for HRV samples, I'm not seeing anything coming from AirPods Pro 3. The device is obviously capable of tracking heart rate continuously during workouts and listening sessions, and from what I've read about the hardware, it should theoretically be able to capture the inter-beat intervals needed for HRV calculation. But either that data isn't being processed on-device, or it's just not being made available through the standard HealthKit data types that third-party apps can access. What I'm really after is either direct HRV metrics (like SDNN, which Apple Watch already provides through HKQuantityTypeIdentifierHeartRateVariabilitySDNN) or even better, access to the raw R-R interval data. With R-R intervals, I could calculate RMSSD, pNN50, and other time-domain and frequency-domain HRV metrics that are super valuable for tracking recovery, autonomic nervous system balance, and stress levels. This would be especially useful since a lot of users wear AirPods during activities when they're not wearing their Apple Watch. Has anyone managed to find a way to pull this data from AirPods Pro 3? Are there any private frameworks or entitlements I should be looking into? Or is this just fundamentally not exposed to developers at the OS level right now? I've gone through the HealthKit documentation pretty thoroughly and haven't found anything that specifically addresses this, but I'm wondering if I'm missing something or if there are any known workarounds. I'm also curious if anyone has heard anything from Apple about future plans to expose this data. It seems like a missed opportunity given how capable the hardware is and how much value developers could provide with access to this physiological data. Would love to hear if anyone else is working on similar features or has insights into the technical limitations here.
1
0
638
Oct ’25
HealthKit in React Native + Expo Dev Client: no authorization prompt (and no data)
Hi everyone, I’m building a health app with React Native using Expo Dev Client on a real iPhone. I need to read Apple Health (HealthKit) data, but the authorization sheet never appears—so the app never gets permissions and all queries return nothing. What I’ve already done Enabled HealthKit capability for the iOS target. Added NSHealthShareUsageDescription and NSHealthUpdateUsageDescription to Info.plist. Using a custom dev build (not Expo Go). Tested fresh installs (deleted the app), rebooted device, and checked Settings → Privacy & Security → Health/Motion & Fitness. Tried both packages: react-native-health and @kingstinct/react-native-healthkit. Same behavior: no permission dialog at first use. Ask Is there a known reason why the HealthKit permission sheet would not show on modern iOS when called from a React Native bridge (with Expo Dev Client)? Are there any extra entitlements, signing, or config-plugin steps required beyond HealthKit capability + Info.plist? If you’re successfully fetching Apple Health data from React Native on recent iOS, could you share the exact steps that made the permission sheet appear and data flow (Expo config/plugin used, Xcode capability setup, profile/team settings, build type, bundle ID nuances, any Health app reset steps, etc.)? This would help me and others hitting the same “authorized call but no prompt/no data” issue. Thank you!
1
0
120
Oct ’25
Is there any way to access real-time sleep stage data from Apple Watch?
I'm trying to make a watchOS app that uses sleep data to wake users up when they enter lighter sleep stages. Apple has HealthKit, which exposes HKCategoryValueSleepAnalysis to view each stage throughout sleep, but unfortunately, this data is only written after the user wakes up. I did some research and found that the Apple Watch’s sleep classifier is part of Apple’s private system process, and apps can’t access that model directly or as it’s running. So, there’s no way to “record” my own data stream and match it with Apple’s classification during the night. Has anyone found a way to approximate or access live sleep-stage data in another way? I’m thinking of combining CoreMotion (for movement) and heart rate data from a HKWorkoutSession to infer stages myself, but I’m wondering if there’s any Apple-approved or more accurate approach for this. In other words, is there any way to use an Apple Watch to detect sleep stages accurately while the user is still asleep for the purpose of timing an optimal wake-up? Thanks
1
0
162
Oct ’25
WatchOS HealthKit HKObserverQuery crashes in background
I have a watchOS app with a connected iOS app using Swift and SwiftUI. The watchOS app should read heart rate date in the background using HKOberserQuery and enableBackgroundDelivery(), send the data to the iPhone app via WCSession. The iPhone app then sends the data to a Firebase project. The issue I am facing now it that the app with the HKObserverQuery works fine when the app is in the foreground, but when the app runs in the background, the observer query gets triggered for the first time (after one hour), but then always get terminated from the watchdog timeout with the following error message: CSLHandleBackgroundHealthKitQueryAction scene-create watchdog transgression: app<app.nanacare.nanacare.nanaCareHealthSync.watchkitapp((null))>:14451 exhausted real (wall clock) time allowance of 15.00 seconds I am using Xcode 16.3 on MacOS 15.4 The App is running on iOS 18.4 and watchOS 11.4 What is the reason for this this issue? I only do a simple SampleQuery to fetch the latest heart rate data inside the HKObserverQuery and then call the completionHandler. The query itself takes less than one second. Or is there a better approach to read continuously heart rate data from healthKit in the background on watchOS? I don't have an active workout session, and I don't need all heart rate data. Once every 15 minutes or so would be enough.
10
1
466
Oct ’25
HKObserverQuery stops delivering updates in background on watchOS 26
Hello, I’m building a health-related app for both watchOS and iOS, which needs to monitor certain health data (e.g., heart rate, active energy). Before updating to watchOS 26, the queries worked reliably without any issues. However, after adapting to watchOS 26, some users have reported that health data updates stop being delivered. What I’ve observed: HKObserverQuery with enableBackgroundDelivery is set up normally. On WatchOS 26, the query sometimes stops delivering updates entirely after a certain point, and once an update is missed, it may stop delivering further updates completely. Restarting the Apple Watch temporarily restores delivery, but the problem reoccurs after some time. This makes background health data monitoring unreliable for my app. Here’s a simplified version of the code we are using: guard let heartType = HKObjectType.quantityType(forIdentifier: .heartRate) else { return } let query = HKObserverQuery(sampleType: heartType, predicate: nil) { query, completionHandler, error in if let error = error { logEvent("Observer error: \(error.localizedDescription)") return } logEvent("Heart rate changed") MyNotificationManager.shared.sendNotification() // Send a local notification completionHandler() } healthStore.execute(query) healthStore.enableBackgroundDelivery(for: heartType, frequency: .hourly) { success, error in if success { logEvent("Background heart rate delivery enabled") } else { logEvent("Failed to enable background heart rate delivery: \(error?.localizedDescription ?? "Unknown error")") } } Could you please clarify: Is this a known issue with HKObserverQuery and enableBackgroundDelivery on watchOS 26? Are there any recommended workarounds or best practices to ensure continuous background delivery of health data? Thank you in advance for your help.
9
1
537
Oct ’25