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

200 Posts

Post

Replies

Boosts

Views

Activity

HKWorkoutBuilder.finishWorkout() fails silently (nil workout, nil error) when device is locked (iOS 26.4+)
Hello everyone, We are encountering a critical regression introduced in iOS 26.4 that results in permanent workout data loss for users. When invoking HKWorkoutBuilder.finishWorkout(completion:) while the iOS device is locked, the save operation fails completely. However, it fails silently: the completion handler executes but returns both a nil workout and a nil error. Expected Behavior: Before iOS 26.4 finishWorkout resulted in a workout id, and correctly stored the workout data in HealthKit. According to HealthKit data protection documentation, saving data when the device is locked should either succeed (writing to a temporary journal file to be merged upon unlock) or explicitly throw an error such as HKError.Code.errorDatabaseInaccessible. Actual Behavior: Because the framework returns nil for both the object and the error, the application has no way to detect that the save failed. We cannot implement a retry mechanism or queue the save, resulting in silent data loss. Steps to Reproduce: We have built a Minimal Reproducible Example (MRE) that reliably triggers this: Initialize an HKWorkoutBuilder and call beginCollection(withStart:) followed by endCollection(withEnd:). Wrap the finishWorkout call in a short 5-second asynchronous delay, protected by a UIBackgroundTask to prevent app suspension. Lock the physical device during this 5-second window. The finishWorkout completion handler will execute while the device is locked, returning workout == nil and error == nil. Existing Reports: We have filed this via Feedback Assistant (a month ago) and opened a TSI (a week ago), providing the MRE project and a sysdiagnose captured at the time of failure: Feedback ID: FB22396180 TSI Case-ID: 19755043 As we have not yet received a response or a suggested workaround through these official channels, we are reaching out to the community. Has anyone else encountered this silent failure with HKWorkoutBuilder recently? Any insights or escalation help would be greatly appreciated.
6
2
641
11h
Please add Sleep Tracking support for Family Setup Apple Watches
Hi everyone, I’d love to see Apple add full Sleep Tracking support for Apple Watches that are set up using Family Setup. Many families use Family Setup for children or older family members who don’t have an iPhone of their own. Sleep is one of the most important health metrics, and it would be incredibly useful if caregivers could view sleep duration and trends just like they can with other health features. This would help parents better understand their child’s sleep habits and would also be valuable for families caring for older adults. Even if detailed health data stayed private, allowing sleep summaries to sync through Family Setup would make the feature much more useful. I hope Apple considers adding this in a future watchOS update. Is this something anyone else would find helpful?
0
0
31
1d
HKStatisticsCollectionQueryDescriptor intermittently returns no data for certain date ranges on iOS 27
We are seeing inconsistent results from HKStatisticsCollectionQueryDescriptor on iOS 27. Using the same quantity type, statistics options, anchor date, interval components, and predicate configuration, some date ranges return the expected statistics, while other ranges unexpectedly return empty results or buckets with no quantity. The affected ranges do contain HealthKit samples: HKSampleQueryDescriptor finds samples in the same date range. HKStatisticsQueryDescriptor returns the expected value when run separately for an affected bucket. HKStatisticsCollectionQueryDescriptor returns no quantity for that same bucket. Slightly expanding or shifting the date range may cause the collection query to return data again. A simplified version of the query looks like this: let datePredicate = HKQuery.predicateForSamples( withStart: startDate, end: endDate, options: .strictStartDate ) let descriptor = HKStatisticsCollectionQueryDescriptor( predicate: .quantitySample( type: quantityType, predicate: datePredicate ), options: .cumulativeSum, anchorDate: anchorDate, intervalComponents: DateComponents(day: 1) ) let collection = try await descriptor.result(for: healthStore) collection.enumerateStatistics(from: startDate, to: endDate) { statistics, _ in let quantity = statistics.sumQuantity() print(statistics.startDate, quantity as Any) } Expected behavior Every interval containing matching samples should return the corresponding statistics, regardless of the overall requested date range. Actual behavior Some date ranges produce missing or empty buckets even though matching samples exist and an individual HKStatisticsQueryDescriptor can calculate the expected value. Changing only the date range can make the data appear or disappear. The samples are visible to the app in the affected range, so this does not appear to be explained solely by iOS 27’s Limited History authorization. This behavior was not observed with the same query flow on earlier iOS versions. Is this a known regression in HKStatisticsCollectionQueryDescriptor on iOS 27, or has the expected date-range or predicate behavior changed?
0
0
68
4d
Track workouts with HealthKit on iOS + GPS tracking
I've built an iOS app according to this WWDC25 video (https://developer.apple.com/videos/play/wwdc2025/322). I added GPS tracking for workouts. In Xcode, I've enabled Signing & Capabilities > Background Modes: Location Updates. And in my code, I request CLAuthorisationStatus.authorizedAlways. Everything works as expected, but I am unsure if .authorizedWhenInUse will not be sufficient for this kind of app. It seems even to work when I use .authorizedWhenInUse as either the Dynamic Island or the Live Activity is shown when the app is not in the foreground. I need clarification by an expert.
1
0
447
4d
HKWorkoutBuilder.finishWorkout intermittently returns nil workout and nil error while samples are successfully saved (iOS 26.4–27)
We're seeing an intermittent issue with HKWorkoutBuilder.finishWorkout() in our production app. Our workflow is: builder.beginCollection(withStart: start) { success, error in guard success else { return } let authorizedSamples = samples.filter { self.healthStore.authorizationStatus(for: $0.quantityType) == .sharingAuthorized } builder.add(authorizedSamples) { success, error in guard success else { return } builder.endCollection(withEnd: end) { success, error in guard success else { return } builder.finishWorkout { workout, error in print("workout = \(String(describing: workout))") print("error = \(String(describing: error))") } } } } The logs from affected users are: workout builder begin: result: true, error: nil authorized samples: - HKQuantityTypeIdentifierActiveEnergyBurned - HKQuantityTypeIdentifierDistanceWalkingRunning - HKQuantityTypeIdentifierStepCount workout builder add samples: result: true, error: nil workout builder end: result: true, error: nil workout builder finish: workout: nil, error: nil Result The quantity samples (active energy, distance, step count, etc.) are successfully written to Apple Health. However, no HKWorkout is created. Querying HealthKit immediately afterward also confirms that no HKWorkout exists for the corresponding time range. As a result: The workout does not appear in the Fitness app. It does not contribute to Activity Rings. The quantity samples are visible, but there is no associated workout. Environment We've received reports from multiple users on: iOS 26.4 iOS 26.5 iOS 26.6 iOS 27 beta The issue only affects a small percentage of users. The vast majority complete successfully using exactly the same code path. Things we've verified We've ruled out several common causes: The app is in the foreground (UIApplication.shared.applicationState == .active). The device is unlocked. All HealthKit write permissions have been granted. finishWorkout() is called immediately after endCollection() completes. The quantity samples are successfully saved. Querying HealthKit afterward confirms that the HKWorkout itself was never created. This appears to be different from the documented "device locked" behavior, since the device is unlocked and active when the issue occurs. We also found a related discussion: https://developer.apple.com/forums/thread/825838 In that thread, the issue seems to be related to a locked device. However, our issue also occurs while the device is unlocked and the app remains active. Has anyone experienced similar behavior? Have you found any workaround? Has Apple provided any update through Feedback Assistant or DTS? Has anyone successfully recovered from this state by retrying finishWorkout() or using another approach? We're happy to provide additional logs or a minimal reproducible example if that would be helpful.
0
0
88
1w
Guidance on HealthKit data storage/sharing practices for App Review (Guideline 5.1.1 / 5.1.3)
Hi all, I'm preparing to submit a watchOS app that only reads HealthKit heart rate data (HKQuantityTypeIdentifierHeartRate) and I want to make sure my storage and sharing practices won't trigger a rejection under Guidelines 5.1.1 (Data Collection and Storage) and 5.1.3 (Health and Health Research). Some specifics about my app: it's an Apple Watch app that reads heart rate only via HealthKit. Data is stored locally on the device first, then uploaded to my own backend server. It's not shared with any third parties (no analytics/ad SDKs touch this data). The uploaded heart rate data is displayed back to the user in a front-end heart rate viewer. My questions: Does uploading HealthKit heart rate data from local storage to my own backend server automatically raise review scrutiny, or is it acceptable as long as it's disclosed in the privacy policy and App Privacy Nutrition Label? Since I'm not sharing data with any third parties, does that satisfy Guideline 5.1.3's restriction on using HealthKit data for advertising or data-mining, or are there other requirements around server-side storage of health data specifically (e.g., encryption at rest/in transit, retention limits)? Is there a preferred way to document this data flow (device to backend) in the app submission, such as App Privacy details, HealthKit usage description, or Health & Fitness disclosures, that reviewers specifically look for to avoid a rejection or follow-up request? Has anyone had a watchOS app rejected for HealthKit-related data practices recently, and if so, what was the specific issue and how did you resolve it? I've read the Health & Fitness guidelines and the HealthKit documentation, but I'd appreciate real-world experience from anyone who has shipped a similar app, especially around what reviewers actually flag in practice. Thanks in advance.
0
0
92
1w
Custom Exported Workout missing workoutPlan identifier / Metadata only on the very first app launch/install
Hello everyone, I am experiencing a strange issue regarding retrieving a custom tracking identifier (workoutPlan identifier) from a custom exported workout that has been imported via HealthKit. The Issue: First Fresh Install: When the app is installed for the first time and initialized, it fails to load/fetch the workout plan ID from the imported workout. Subsequent Launches / Re-installs: If I close and relaunch the app, the app successfully fetches the workout plan ID from HealthKit with absolutely no problems. Has anyone found a clean way to handle this without forcing a manual user refresh or an awkward delay/retry mechanism on the first launch? Any insight, workarounds, or best practices would be greatly appreciated! Environment: iOS 17+, Swift, HealthKit
3
0
163
1w
Custom Exported Workout missing workoutPlan identifier / Metadata only on the very first app launch/install
Hello everyone, I am experiencing a strange issue regarding retrieving a custom tracking identifier (workoutPlan identifier) from a custom exported workout that has been imported via HealthKit. The Issue: First Fresh Install: When the app is installed for the first time and initialized, it fails to load/fetch the workout plan ID from the imported workout. Subsequent Launches / Re-installs: If I close and relaunch the app, the app successfully fetches the workout plan ID from HealthKit with absolutely no problems. Has anyone found a clean way to handle this without forcing a manual user refresh or an awkward delay/retry mechanism on the first launch? Any insight, workarounds, or best practices would be greatly appreciated! Environment: iOS 17+, Swift, HealthKit
1
0
118
1w
Unable to invalidate interval: no data source available error when fetching steps using HKStatisticsCollectionQuery
While attempting to read a user’s daily step history spanning backward to the last 7 days, a small but consistent subset of users encounter Error Code 3 with the underlying error description: Error Code 3 "Unable to invalidate interval: no data source available." When this error occurs, we are entirely unable to read their step history. We have received ~10 direct user reports of this within the last couple of weeks.
14
2
1.4k
2w
Feature Proposal: Apple Intelligence Guided Workouts for Apple Watch
Hi everyone, After watching WWDC26 and going for a run today, I came up with an idea that I believe could be a natural extension of Apple Intelligence and Apple Watch. This proposal is not intended to replace Custom Workouts. Instead, it focuses on removing the manual setup required to create them by allowing Apple Intelligence to understand workout plans written in natural language. Today, Apple Watch already supports Custom Workouts, but users still have to manually recreate interval workouts. For example: • Walk 5 minutes • Run 1 minute • Walk 1 minute 30 seconds • Repeat 6 times Instead, Apple Intelligence could understand workouts written in natural language and automatically generate a structured Apple Watch workout. This could work from multiple sources: Notes Messages Mail PDFs Screenshots Photos of printed training plans Websites The generated workout could then be reviewed by the user before being saved and synchronized to Apple Watch. Intelligent Haptics I also imagined an optional feature called Intelligent Haptics. Instead of using a single vibration for interval transitions, the watch could communicate through different haptic patterns: Progressive vibration before a running interval starts. Decreasing vibration when an interval ends. Rhythmic vibrations during recovery to help regulate breathing. The goal isn't simply to notify the user—it is to reduce the need to constantly look at the display and allow them to stay focused on the workout. Since Apple Intelligence is becoming a system-wide capability, I think workouts could be understood just like calendar events, reminders or emails. I have already submitted this proposal through Feedback Assistant, but I would love to hear what other developers think. Would this be a feature you would like to see in watchOS? I'm curious to hear how other developers would improve this concept.
0
0
258
3w
HKStatisticsCollectionQuery initialResultsHandler returns nil results (error) for one specific user — read auth granted, data exists, survives reinstall
Environment: iPhone 13 Pro, iOS 26.5. Affects a single user out of many; cannot reproduce on any of our test devices. We use HKStatisticsCollectionQuery to read step counts for a statistics screen. For one specific user, the query's initialResultsHandler appears to deliver results == nil (the success branch never runs), so our completion is never called and the screen shows an infinite spinner. private let store = HKHealthStore() func fetchHourlyStepCounts(for day: Date, completion: @escaping ([Int]) -> Void) { guard let stepType = HKQuantityType.quantityType(forIdentifier: .stepCount) else { return } let calendar = Calendar.current let startOfDay = calendar.startOfDay(for: day) var hourly = DateComponents() hourly.hour = 1 let query = HKStatisticsCollectionQuery( quantityType: stepType, quantitySamplePredicate: nil, options: .cumulativeSum, anchorDate: startOfDay, intervalComponents: hourly ) query.initialResultsHandler = { _, collection, error in guard let collection else { // For the affected user, execution seems to reach here (collection == nil). // Adding logging of the HKError + authorization status for the next occurrence. return } var counts: [Int] = [] let end = calendar.date(byAdding: .day, value: 1, to: startOfDay)! collection.enumerateStatistics(from: startOfDay, to: end) { stats, _ in let steps = stats.sumQuantity()?.doubleValue(for: .count()) ?? 0 counts.append(Int(steps)) } DispatchQueue.main.async { completion(counts) } } store.execute(query) } What we've confirmed / ruled out: Read authorization for stepCount is granted (the user toggled it ON in the HealthKit sheet on video). The Apple Health app shows step data for this user (so data exists). A coarser query (2-year interval) for the same user succeeds, while the hourly query appears to fail — same type / predicate / options / auth. Symptom persists across app reinstall and device reboot, and re-granting Health permission. Permission denial returns empty results (per Apple docs), not an error — so this isn't simple denial. Not errorDatabaseInaccessible as far as we can tell (foreground, device unlocked). Questions: What can cause HKStatisticsCollectionQuery.initialResultsHandler to return results == nil (with an error) persistently for one device/account, when read auth is granted and data exists? Can errorHealthDataRestricted occur without an MDM/supervised profile (i.e., on a normal consumer device)? What device/account states actually trigger it? Is it expected that a coarse-interval query succeeds while an hourly-interval query on the same type fails for the same user? We're adding logging of the actual HKError code + authorizationStatus for the next occurrence, but would appreciate any insight on what conditions produce this.
0
0
271
3w
Why does a watchOS HKLiveWorkoutBuilder soccer workout report shorter totalDistance than Apple Workout soccer?
I’m developing a watchOS app that records outdoor soccer workouts using HealthKit. My app starts a workout session with: HKWorkoutConfiguration.activityType = .soccer HKWorkoutConfiguration.locationType = .outdoor HKWorkoutSession HKLiveWorkoutBuilder HKLiveWorkoutDataSource During the workout, I display distance from the live builder statistics: HKQuantityType.quantityType(forIdentifier: .distanceWalkingRunning) After the workout ends, I save the workout using finishWorkout(), and later read the saved distance from: HKWorkout.totalDistance?.doubleValue(for: .meter()) So the total distance shown in my app is not calculated manually from GPS route points. It comes from HealthKit’s workout distance. I noticed a difference between soccer workouts recorded by Apple’s built-in Workout app and soccer workouts recorded by my third-party watchOS app. Example comparison: Apple Workout app soccer: Active duration: about 88 min Steps: about 8,832 Distance: about 6.7 km No visible route/location data in Fitness My watchOS app soccer: Active duration: about 87 min Steps: about 8,998 Distance: about 5.6 km Includes route/location data Workout recorded through HKWorkoutSession + HKLiveWorkoutBuilder Distance read from HKWorkout.totalDistance The step counts and active durations are very close, but the distance differs by about 1.1 km. One important detail is that the Apple Workout app soccer workout does not appear to include visible route/location data in Fitness, while my third-party workout does include route/location data. Despite that, the Apple Workout app reports a longer distance. So the comparison is not simply “GPS route distance vs GPS route distance”. It looks like the built-in Workout app may be estimating soccer distance without exposing route data, while HKLiveWorkoutBuilder for a third-party .soccer workout may be producing a different totalDistance estimate. My questions are: When the built-in Apple Workout app records an outdoor soccer workout without exposing route data, how is totalDistance estimated? Is that distance estimation behavior available to third-party watchOS apps using HKWorkoutSession + HKLiveWorkoutBuilder with .soccer? If a third-party app records route data for the same soccer activity, can that change how HealthKit calculates totalDistance compared with a no-route built-in Workout app recording? For third-party soccer workouts, should developers expect HKWorkout.totalDistance to match the built-in Workout app, or is a difference expected? Is there any additional configuration, entitlement, data type, or best practice required to get more accurate distance estimates for soccer workouts? Any clarification on the expected behavior would be very helpful. Thanks!
0
1
361
3w
HealthKit multiple queries performance questions
We're building two apps that rely almost exclusively on HealthKit, so we run a high volume of queries against a single shared HKHealthStore — mostly HKSampleQuery, plus HKStatisticsQuery and HKQuantitySeriesSampleQuery where needed. We also use HKObserverQuery for background processing and widget updates. The data is sleep, body metrics, and workouts. As our feature set grew, so did data-loading time, to the point of being a noticeable annoyance for users. To speed things up we moved from serial to concurrent queries. Mechanism: we issue the batch via a ThrowingTaskGroup — each child task calls execute() and awaits the completion handler through a continuation — with up to ~30 queries in flight concurrently against the one shared store. Symptom: The app doesn't freeze and the queries start fine, but their results sometimes take 30s+ to come back. Most of the times the same data fetch takes only a couple of seconds. There's no clear pattern except that it happens far more often on foregrounding. Environment: Devices we use for testing are iPhone 17 Pro and iPhone 15 pro both running iOS 26.5. Since the symptoms are hard to catch we're using text file logging to time the data layer responses. We're considering bounding concurrency to a small N via a capped task group, or reverting to serial — but both feel like either a regression or added complexity we can't justify without understanding the real cause. Questions: When we start ~30 queries at once against a single HKHealthStore, does HealthKit actually run them in parallel, or do they get handled one-at-a-time (or rate-limited) behind the scenes? Is there a sensible upper limit on how many queries we should run at once? Should we cap it to a small number, or does that not help because the system serializes them anyway? (Also: is sharing one HKHealthStore across the app the right approach?) Why would this happen mainly when the app comes to the foreground? A few possibilities we'd like confirmed or ruled out: the device hasn't been unlocked yet so health data isn't available, the connection to the HealthKit service is being re-established after backgrounding, general contention, or our background HKObserverQuery work blocking the foreground queries. Can HKObserverQuery background work get in the way of foreground queries? If so, is there a recommended way to pause or coordinate it when the app becomes active? Thank you
0
1
318
4w
HealthKit Blood Pressure authorization broken on iOS 26.5 RC
Hello, I'm experiencing a bug on iOS 26.5 RC1/RC2 where the Blood Pressure option is silently excluded from the HealthKit permission dialog (when requesting HKQuantityTypeIdentifierBloodPressureSystolic and HKQuantityTypeIdentifierBloodPressureDiastolic). This does not reproduce on iOS 26.4.2 or earlier. What happens: When BP types are requested alone, a blank white modal slides up and immediately dismisses — no permission UI is shown. When BP is requested alongside other types, a normal dialog appears for those other types, but Blood Pressure is simply absent from the list. The completion handler returns success = YES, error = nil in both cases, but BP permission is never granted. The result: Settings → Privacy & Security → Health → [app] shows Blood Pressure as requested but not granted getRequestStatusForAuthorizationToShareTypes for the BP types keeps returning ShouldRequest indefinitely HealthKit queries for BP samples return no data Workaround: Manually toggling Blood Pressure to ON in Settings → Privacy & Security → Health → [app name] fixes everything - queries work, notifications fire, and getRequestStatusForAuthorizationToShareTypes correctly returns HKAuthorizationRequestStatusUnnecessary. Environment: Confirmed broken: iOS 26.5 RC1 (23F75) and RC2 (23F77), iPhone 11; iOS 26.5 RC1 (23F73), simulator Confirmed working: iOS 26.4.2 (device), iOS 26.4.1 (simulator) Feedback filed as FB22735935.
12
11
2.7k
Jun ’26
"Failed to register bundle identifier" for teammates — caused by App Groups/HealthKit forcing an explicit App ID?
I'm trying to let a few teammates build and run my app on their own devices, and I'd like to understand the correct approach for our situation. Setup We are a small team. Each of us uses a free personal Apple Developer team (individual Apple IDs, no paid membership yet). The app (an iOS app with a Watch app and a WidgetKit extension) uses App Groups and HealthKit. Bundle IDs: com.example.MyApp, com.example.MyApp.watchkitapp, com.example.MyApp.Widget. App Group: group.example.MyApp. It builds fine for me. When a teammate opens the project and tries to run on device, they get: Failed Registering Bundle Identifier The app identifier "com.example.MyApp" cannot be registered to your development team because it is not available. Change your bundle dentifier to a unique string to try again. What I've observed My other apps that have no entitlements build fine for every teammate. Looking at their embedded profiles, those sign with a wildcard profile (TEAMID.*). This app signs with an explicit profile (TEAMID.com.example.MyApp). If a teammate removes HealthKit and App Groups from all targets, the app builds for them under their own team using the same bundle ID. My understanding (please correct me) App Groups and HealthKit require an explicit App ID, which can only be registered to one team. Since I registered com.example.MyApp first, no other personal team can register the same explicit App ID hence the error. My questions Is that understanding correct — that an entitled (explicit) App ID can only ever belong to a single team? Is there any supported way to keep the same bundle identifier and keep App Groups + HealthKit while teammates build under their own separate personal teams? Or is moving to an Organization account (everyone as members of one shared team) the only way to share an entitled bundle ID across multiple developers? For free personal-team development, is the recommended pattern to give each developer a unique bundle ID + App Group (e.g. via per-developer .xcconfig), keeping entitlements intact? Just want to confirm I'm choosing the right approach before committing to it. Thanks!
1
0
194
Jun ’26
Detecting External Heart Rate Monitor Availability
I've noticed that the Fitness app on the iPhone can rapidly detect the presence of an Apple Watch or External Heart Rate Monitor (e.g., AirPods Pro 3) so that it can adjust the availability of certain exercise types. Is this done through an API that is public? Can third party fitness apps access similar functionality so users can be pre-alerted to the availability of workout types that require a heart rate sensor of some sort?
2
0
513
Jun ’26
How long does Apple Watch keep HealthKit data?
I would like to create an Apple Watch only app that queries data such as blood oxygenation, heart varibility, number of steps, energy consumed, and other data of a similar nature recorded over the past month and performs calculations on them. I read from the HealthKit documentation that Apple Watch synchronizes data with iPhone and periodically deletes older data, and that I can get the date from which the data is available with earliestPermittedSampleDate(). Is there a risk that in general, by making queries to retrieve data up to a month old, the data will no longer be available? I need the app to work properly without needing an iPhone.
5
1
2.7k
Jun ’26
Indoor workout location
In the Fitness app under iOS 26, each workout location is displayed on a small map. For workouts with routes, I can already successfully read out the route and thus also determine the starting point. So that works. For indoor workouts such as yoga or indoor rowing, the exact location is also displayed in the Fitness app. I would now also like to read out this location for these indoor workouts in my app. Does anyone know how to do this?
1
0
488
May ’26
HKWorkoutBuilder.finishWorkout() fails silently (nil workout, nil error) when device is locked (iOS 26.4+)
Hello everyone, We are encountering a critical regression introduced in iOS 26.4 that results in permanent workout data loss for users. When invoking HKWorkoutBuilder.finishWorkout(completion:) while the iOS device is locked, the save operation fails completely. However, it fails silently: the completion handler executes but returns both a nil workout and a nil error. Expected Behavior: Before iOS 26.4 finishWorkout resulted in a workout id, and correctly stored the workout data in HealthKit. According to HealthKit data protection documentation, saving data when the device is locked should either succeed (writing to a temporary journal file to be merged upon unlock) or explicitly throw an error such as HKError.Code.errorDatabaseInaccessible. Actual Behavior: Because the framework returns nil for both the object and the error, the application has no way to detect that the save failed. We cannot implement a retry mechanism or queue the save, resulting in silent data loss. Steps to Reproduce: We have built a Minimal Reproducible Example (MRE) that reliably triggers this: Initialize an HKWorkoutBuilder and call beginCollection(withStart:) followed by endCollection(withEnd:). Wrap the finishWorkout call in a short 5-second asynchronous delay, protected by a UIBackgroundTask to prevent app suspension. Lock the physical device during this 5-second window. The finishWorkout completion handler will execute while the device is locked, returning workout == nil and error == nil. Existing Reports: We have filed this via Feedback Assistant (a month ago) and opened a TSI (a week ago), providing the MRE project and a sysdiagnose captured at the time of failure: Feedback ID: FB22396180 TSI Case-ID: 19755043 As we have not yet received a response or a suggested workaround through these official channels, we are reaching out to the community. Has anyone else encountered this silent failure with HKWorkoutBuilder recently? Any insights or escalation help would be greatly appreciated.
Replies
6
Boosts
2
Views
641
Activity
11h
Please add Sleep Tracking support for Family Setup Apple Watches
Hi everyone, I’d love to see Apple add full Sleep Tracking support for Apple Watches that are set up using Family Setup. Many families use Family Setup for children or older family members who don’t have an iPhone of their own. Sleep is one of the most important health metrics, and it would be incredibly useful if caregivers could view sleep duration and trends just like they can with other health features. This would help parents better understand their child’s sleep habits and would also be valuable for families caring for older adults. Even if detailed health data stayed private, allowing sleep summaries to sync through Family Setup would make the feature much more useful. I hope Apple considers adding this in a future watchOS update. Is this something anyone else would find helpful?
Replies
0
Boosts
0
Views
31
Activity
1d
HKStatisticsCollectionQueryDescriptor intermittently returns no data for certain date ranges on iOS 27
We are seeing inconsistent results from HKStatisticsCollectionQueryDescriptor on iOS 27. Using the same quantity type, statistics options, anchor date, interval components, and predicate configuration, some date ranges return the expected statistics, while other ranges unexpectedly return empty results or buckets with no quantity. The affected ranges do contain HealthKit samples: HKSampleQueryDescriptor finds samples in the same date range. HKStatisticsQueryDescriptor returns the expected value when run separately for an affected bucket. HKStatisticsCollectionQueryDescriptor returns no quantity for that same bucket. Slightly expanding or shifting the date range may cause the collection query to return data again. A simplified version of the query looks like this: let datePredicate = HKQuery.predicateForSamples( withStart: startDate, end: endDate, options: .strictStartDate ) let descriptor = HKStatisticsCollectionQueryDescriptor( predicate: .quantitySample( type: quantityType, predicate: datePredicate ), options: .cumulativeSum, anchorDate: anchorDate, intervalComponents: DateComponents(day: 1) ) let collection = try await descriptor.result(for: healthStore) collection.enumerateStatistics(from: startDate, to: endDate) { statistics, _ in let quantity = statistics.sumQuantity() print(statistics.startDate, quantity as Any) } Expected behavior Every interval containing matching samples should return the corresponding statistics, regardless of the overall requested date range. Actual behavior Some date ranges produce missing or empty buckets even though matching samples exist and an individual HKStatisticsQueryDescriptor can calculate the expected value. Changing only the date range can make the data appear or disappear. The samples are visible to the app in the affected range, so this does not appear to be explained solely by iOS 27’s Limited History authorization. This behavior was not observed with the same query flow on earlier iOS versions. Is this a known regression in HKStatisticsCollectionQueryDescriptor on iOS 27, or has the expected date-range or predicate behavior changed?
Replies
0
Boosts
0
Views
68
Activity
4d
Track workouts with HealthKit on iOS + GPS tracking
I've built an iOS app according to this WWDC25 video (https://developer.apple.com/videos/play/wwdc2025/322). I added GPS tracking for workouts. In Xcode, I've enabled Signing & Capabilities > Background Modes: Location Updates. And in my code, I request CLAuthorisationStatus.authorizedAlways. Everything works as expected, but I am unsure if .authorizedWhenInUse will not be sufficient for this kind of app. It seems even to work when I use .authorizedWhenInUse as either the Dynamic Island or the Live Activity is shown when the app is not in the foreground. I need clarification by an expert.
Replies
1
Boosts
0
Views
447
Activity
4d
HKWorkoutBuilder.finishWorkout intermittently returns nil workout and nil error while samples are successfully saved (iOS 26.4–27)
We're seeing an intermittent issue with HKWorkoutBuilder.finishWorkout() in our production app. Our workflow is: builder.beginCollection(withStart: start) { success, error in guard success else { return } let authorizedSamples = samples.filter { self.healthStore.authorizationStatus(for: $0.quantityType) == .sharingAuthorized } builder.add(authorizedSamples) { success, error in guard success else { return } builder.endCollection(withEnd: end) { success, error in guard success else { return } builder.finishWorkout { workout, error in print("workout = \(String(describing: workout))") print("error = \(String(describing: error))") } } } } The logs from affected users are: workout builder begin: result: true, error: nil authorized samples: - HKQuantityTypeIdentifierActiveEnergyBurned - HKQuantityTypeIdentifierDistanceWalkingRunning - HKQuantityTypeIdentifierStepCount workout builder add samples: result: true, error: nil workout builder end: result: true, error: nil workout builder finish: workout: nil, error: nil Result The quantity samples (active energy, distance, step count, etc.) are successfully written to Apple Health. However, no HKWorkout is created. Querying HealthKit immediately afterward also confirms that no HKWorkout exists for the corresponding time range. As a result: The workout does not appear in the Fitness app. It does not contribute to Activity Rings. The quantity samples are visible, but there is no associated workout. Environment We've received reports from multiple users on: iOS 26.4 iOS 26.5 iOS 26.6 iOS 27 beta The issue only affects a small percentage of users. The vast majority complete successfully using exactly the same code path. Things we've verified We've ruled out several common causes: The app is in the foreground (UIApplication.shared.applicationState == .active). The device is unlocked. All HealthKit write permissions have been granted. finishWorkout() is called immediately after endCollection() completes. The quantity samples are successfully saved. Querying HealthKit afterward confirms that the HKWorkout itself was never created. This appears to be different from the documented "device locked" behavior, since the device is unlocked and active when the issue occurs. We also found a related discussion: https://developer.apple.com/forums/thread/825838 In that thread, the issue seems to be related to a locked device. However, our issue also occurs while the device is unlocked and the app remains active. Has anyone experienced similar behavior? Have you found any workaround? Has Apple provided any update through Feedback Assistant or DTS? Has anyone successfully recovered from this state by retrying finishWorkout() or using another approach? We're happy to provide additional logs or a minimal reproducible example if that would be helpful.
Replies
0
Boosts
0
Views
88
Activity
1w
Guidance on HealthKit data storage/sharing practices for App Review (Guideline 5.1.1 / 5.1.3)
Hi all, I'm preparing to submit a watchOS app that only reads HealthKit heart rate data (HKQuantityTypeIdentifierHeartRate) and I want to make sure my storage and sharing practices won't trigger a rejection under Guidelines 5.1.1 (Data Collection and Storage) and 5.1.3 (Health and Health Research). Some specifics about my app: it's an Apple Watch app that reads heart rate only via HealthKit. Data is stored locally on the device first, then uploaded to my own backend server. It's not shared with any third parties (no analytics/ad SDKs touch this data). The uploaded heart rate data is displayed back to the user in a front-end heart rate viewer. My questions: Does uploading HealthKit heart rate data from local storage to my own backend server automatically raise review scrutiny, or is it acceptable as long as it's disclosed in the privacy policy and App Privacy Nutrition Label? Since I'm not sharing data with any third parties, does that satisfy Guideline 5.1.3's restriction on using HealthKit data for advertising or data-mining, or are there other requirements around server-side storage of health data specifically (e.g., encryption at rest/in transit, retention limits)? Is there a preferred way to document this data flow (device to backend) in the app submission, such as App Privacy details, HealthKit usage description, or Health & Fitness disclosures, that reviewers specifically look for to avoid a rejection or follow-up request? Has anyone had a watchOS app rejected for HealthKit-related data practices recently, and if so, what was the specific issue and how did you resolve it? I've read the Health & Fitness guidelines and the HealthKit documentation, but I'd appreciate real-world experience from anyone who has shipped a similar app, especially around what reviewers actually flag in practice. Thanks in advance.
Replies
0
Boosts
0
Views
92
Activity
1w
Apple Health not connecting Blood Pressure from OMRON App
iOS 27 beta 3 broke my Apple health and blood pressure monitor and according to omron app, everything is being sent to Apple health. All permissions given. But blood pressure will not transfer into health.
Replies
1
Boosts
0
Views
111
Activity
1w
Custom Exported Workout missing workoutPlan identifier / Metadata only on the very first app launch/install
Hello everyone, I am experiencing a strange issue regarding retrieving a custom tracking identifier (workoutPlan identifier) from a custom exported workout that has been imported via HealthKit. The Issue: First Fresh Install: When the app is installed for the first time and initialized, it fails to load/fetch the workout plan ID from the imported workout. Subsequent Launches / Re-installs: If I close and relaunch the app, the app successfully fetches the workout plan ID from HealthKit with absolutely no problems. Has anyone found a clean way to handle this without forcing a manual user refresh or an awkward delay/retry mechanism on the first launch? Any insight, workarounds, or best practices would be greatly appreciated! Environment: iOS 17+, Swift, HealthKit
Replies
3
Boosts
0
Views
163
Activity
1w
Custom Exported Workout missing workoutPlan identifier / Metadata only on the very first app launch/install
Hello everyone, I am experiencing a strange issue regarding retrieving a custom tracking identifier (workoutPlan identifier) from a custom exported workout that has been imported via HealthKit. The Issue: First Fresh Install: When the app is installed for the first time and initialized, it fails to load/fetch the workout plan ID from the imported workout. Subsequent Launches / Re-installs: If I close and relaunch the app, the app successfully fetches the workout plan ID from HealthKit with absolutely no problems. Has anyone found a clean way to handle this without forcing a manual user refresh or an awkward delay/retry mechanism on the first launch? Any insight, workarounds, or best practices would be greatly appreciated! Environment: iOS 17+, Swift, HealthKit
Replies
1
Boosts
0
Views
118
Activity
1w
Dive workout
Hello, How can I read the dive count and total underwater time for a Dive workout from Apple Health? Is this information available through HealthKit, and if so, which APIs or workout metadata keys should I use? Thanks! Stéphane
Replies
2
Boosts
0
Views
209
Activity
2w
Unable to invalidate interval: no data source available error when fetching steps using HKStatisticsCollectionQuery
While attempting to read a user’s daily step history spanning backward to the last 7 days, a small but consistent subset of users encounter Error Code 3 with the underlying error description: Error Code 3 "Unable to invalidate interval: no data source available." When this error occurs, we are entirely unable to read their step history. We have received ~10 direct user reports of this within the last couple of weeks.
Replies
14
Boosts
2
Views
1.4k
Activity
2w
Feature Proposal: Apple Intelligence Guided Workouts for Apple Watch
Hi everyone, After watching WWDC26 and going for a run today, I came up with an idea that I believe could be a natural extension of Apple Intelligence and Apple Watch. This proposal is not intended to replace Custom Workouts. Instead, it focuses on removing the manual setup required to create them by allowing Apple Intelligence to understand workout plans written in natural language. Today, Apple Watch already supports Custom Workouts, but users still have to manually recreate interval workouts. For example: • Walk 5 minutes • Run 1 minute • Walk 1 minute 30 seconds • Repeat 6 times Instead, Apple Intelligence could understand workouts written in natural language and automatically generate a structured Apple Watch workout. This could work from multiple sources: Notes Messages Mail PDFs Screenshots Photos of printed training plans Websites The generated workout could then be reviewed by the user before being saved and synchronized to Apple Watch. Intelligent Haptics I also imagined an optional feature called Intelligent Haptics. Instead of using a single vibration for interval transitions, the watch could communicate through different haptic patterns: Progressive vibration before a running interval starts. Decreasing vibration when an interval ends. Rhythmic vibrations during recovery to help regulate breathing. The goal isn't simply to notify the user—it is to reduce the need to constantly look at the display and allow them to stay focused on the workout. Since Apple Intelligence is becoming a system-wide capability, I think workouts could be understood just like calendar events, reminders or emails. I have already submitted this proposal through Feedback Assistant, but I would love to hear what other developers think. Would this be a feature you would like to see in watchOS? I'm curious to hear how other developers would improve this concept.
Replies
0
Boosts
0
Views
258
Activity
3w
HKStatisticsCollectionQuery initialResultsHandler returns nil results (error) for one specific user — read auth granted, data exists, survives reinstall
Environment: iPhone 13 Pro, iOS 26.5. Affects a single user out of many; cannot reproduce on any of our test devices. We use HKStatisticsCollectionQuery to read step counts for a statistics screen. For one specific user, the query's initialResultsHandler appears to deliver results == nil (the success branch never runs), so our completion is never called and the screen shows an infinite spinner. private let store = HKHealthStore() func fetchHourlyStepCounts(for day: Date, completion: @escaping ([Int]) -> Void) { guard let stepType = HKQuantityType.quantityType(forIdentifier: .stepCount) else { return } let calendar = Calendar.current let startOfDay = calendar.startOfDay(for: day) var hourly = DateComponents() hourly.hour = 1 let query = HKStatisticsCollectionQuery( quantityType: stepType, quantitySamplePredicate: nil, options: .cumulativeSum, anchorDate: startOfDay, intervalComponents: hourly ) query.initialResultsHandler = { _, collection, error in guard let collection else { // For the affected user, execution seems to reach here (collection == nil). // Adding logging of the HKError + authorization status for the next occurrence. return } var counts: [Int] = [] let end = calendar.date(byAdding: .day, value: 1, to: startOfDay)! collection.enumerateStatistics(from: startOfDay, to: end) { stats, _ in let steps = stats.sumQuantity()?.doubleValue(for: .count()) ?? 0 counts.append(Int(steps)) } DispatchQueue.main.async { completion(counts) } } store.execute(query) } What we've confirmed / ruled out: Read authorization for stepCount is granted (the user toggled it ON in the HealthKit sheet on video). The Apple Health app shows step data for this user (so data exists). A coarser query (2-year interval) for the same user succeeds, while the hourly query appears to fail — same type / predicate / options / auth. Symptom persists across app reinstall and device reboot, and re-granting Health permission. Permission denial returns empty results (per Apple docs), not an error — so this isn't simple denial. Not errorDatabaseInaccessible as far as we can tell (foreground, device unlocked). Questions: What can cause HKStatisticsCollectionQuery.initialResultsHandler to return results == nil (with an error) persistently for one device/account, when read auth is granted and data exists? Can errorHealthDataRestricted occur without an MDM/supervised profile (i.e., on a normal consumer device)? What device/account states actually trigger it? Is it expected that a coarse-interval query succeeds while an hourly-interval query on the same type fails for the same user? We're adding logging of the actual HKError code + authorizationStatus for the next occurrence, but would appreciate any insight on what conditions produce this.
Replies
0
Boosts
0
Views
271
Activity
3w
Why does a watchOS HKLiveWorkoutBuilder soccer workout report shorter totalDistance than Apple Workout soccer?
I’m developing a watchOS app that records outdoor soccer workouts using HealthKit. My app starts a workout session with: HKWorkoutConfiguration.activityType = .soccer HKWorkoutConfiguration.locationType = .outdoor HKWorkoutSession HKLiveWorkoutBuilder HKLiveWorkoutDataSource During the workout, I display distance from the live builder statistics: HKQuantityType.quantityType(forIdentifier: .distanceWalkingRunning) After the workout ends, I save the workout using finishWorkout(), and later read the saved distance from: HKWorkout.totalDistance?.doubleValue(for: .meter()) So the total distance shown in my app is not calculated manually from GPS route points. It comes from HealthKit’s workout distance. I noticed a difference between soccer workouts recorded by Apple’s built-in Workout app and soccer workouts recorded by my third-party watchOS app. Example comparison: Apple Workout app soccer: Active duration: about 88 min Steps: about 8,832 Distance: about 6.7 km No visible route/location data in Fitness My watchOS app soccer: Active duration: about 87 min Steps: about 8,998 Distance: about 5.6 km Includes route/location data Workout recorded through HKWorkoutSession + HKLiveWorkoutBuilder Distance read from HKWorkout.totalDistance The step counts and active durations are very close, but the distance differs by about 1.1 km. One important detail is that the Apple Workout app soccer workout does not appear to include visible route/location data in Fitness, while my third-party workout does include route/location data. Despite that, the Apple Workout app reports a longer distance. So the comparison is not simply “GPS route distance vs GPS route distance”. It looks like the built-in Workout app may be estimating soccer distance without exposing route data, while HKLiveWorkoutBuilder for a third-party .soccer workout may be producing a different totalDistance estimate. My questions are: When the built-in Apple Workout app records an outdoor soccer workout without exposing route data, how is totalDistance estimated? Is that distance estimation behavior available to third-party watchOS apps using HKWorkoutSession + HKLiveWorkoutBuilder with .soccer? If a third-party app records route data for the same soccer activity, can that change how HealthKit calculates totalDistance compared with a no-route built-in Workout app recording? For third-party soccer workouts, should developers expect HKWorkout.totalDistance to match the built-in Workout app, or is a difference expected? Is there any additional configuration, entitlement, data type, or best practice required to get more accurate distance estimates for soccer workouts? Any clarification on the expected behavior would be very helpful. Thanks!
Replies
0
Boosts
1
Views
361
Activity
3w
HealthKit multiple queries performance questions
We're building two apps that rely almost exclusively on HealthKit, so we run a high volume of queries against a single shared HKHealthStore — mostly HKSampleQuery, plus HKStatisticsQuery and HKQuantitySeriesSampleQuery where needed. We also use HKObserverQuery for background processing and widget updates. The data is sleep, body metrics, and workouts. As our feature set grew, so did data-loading time, to the point of being a noticeable annoyance for users. To speed things up we moved from serial to concurrent queries. Mechanism: we issue the batch via a ThrowingTaskGroup — each child task calls execute() and awaits the completion handler through a continuation — with up to ~30 queries in flight concurrently against the one shared store. Symptom: The app doesn't freeze and the queries start fine, but their results sometimes take 30s+ to come back. Most of the times the same data fetch takes only a couple of seconds. There's no clear pattern except that it happens far more often on foregrounding. Environment: Devices we use for testing are iPhone 17 Pro and iPhone 15 pro both running iOS 26.5. Since the symptoms are hard to catch we're using text file logging to time the data layer responses. We're considering bounding concurrency to a small N via a capped task group, or reverting to serial — but both feel like either a regression or added complexity we can't justify without understanding the real cause. Questions: When we start ~30 queries at once against a single HKHealthStore, does HealthKit actually run them in parallel, or do they get handled one-at-a-time (or rate-limited) behind the scenes? Is there a sensible upper limit on how many queries we should run at once? Should we cap it to a small number, or does that not help because the system serializes them anyway? (Also: is sharing one HKHealthStore across the app the right approach?) Why would this happen mainly when the app comes to the foreground? A few possibilities we'd like confirmed or ruled out: the device hasn't been unlocked yet so health data isn't available, the connection to the HealthKit service is being re-established after backgrounding, general contention, or our background HKObserverQuery work blocking the foreground queries. Can HKObserverQuery background work get in the way of foreground queries? If so, is there a recommended way to pause or coordinate it when the app becomes active? Thank you
Replies
0
Boosts
1
Views
318
Activity
4w
HealthKit Blood Pressure authorization broken on iOS 26.5 RC
Hello, I'm experiencing a bug on iOS 26.5 RC1/RC2 where the Blood Pressure option is silently excluded from the HealthKit permission dialog (when requesting HKQuantityTypeIdentifierBloodPressureSystolic and HKQuantityTypeIdentifierBloodPressureDiastolic). This does not reproduce on iOS 26.4.2 or earlier. What happens: When BP types are requested alone, a blank white modal slides up and immediately dismisses — no permission UI is shown. When BP is requested alongside other types, a normal dialog appears for those other types, but Blood Pressure is simply absent from the list. The completion handler returns success = YES, error = nil in both cases, but BP permission is never granted. The result: Settings → Privacy & Security → Health → [app] shows Blood Pressure as requested but not granted getRequestStatusForAuthorizationToShareTypes for the BP types keeps returning ShouldRequest indefinitely HealthKit queries for BP samples return no data Workaround: Manually toggling Blood Pressure to ON in Settings → Privacy & Security → Health → [app name] fixes everything - queries work, notifications fire, and getRequestStatusForAuthorizationToShareTypes correctly returns HKAuthorizationRequestStatusUnnecessary. Environment: Confirmed broken: iOS 26.5 RC1 (23F75) and RC2 (23F77), iPhone 11; iOS 26.5 RC1 (23F73), simulator Confirmed working: iOS 26.4.2 (device), iOS 26.4.1 (simulator) Feedback filed as FB22735935.
Replies
12
Boosts
11
Views
2.7k
Activity
Jun ’26
"Failed to register bundle identifier" for teammates — caused by App Groups/HealthKit forcing an explicit App ID?
I'm trying to let a few teammates build and run my app on their own devices, and I'd like to understand the correct approach for our situation. Setup We are a small team. Each of us uses a free personal Apple Developer team (individual Apple IDs, no paid membership yet). The app (an iOS app with a Watch app and a WidgetKit extension) uses App Groups and HealthKit. Bundle IDs: com.example.MyApp, com.example.MyApp.watchkitapp, com.example.MyApp.Widget. App Group: group.example.MyApp. It builds fine for me. When a teammate opens the project and tries to run on device, they get: Failed Registering Bundle Identifier The app identifier "com.example.MyApp" cannot be registered to your development team because it is not available. Change your bundle dentifier to a unique string to try again. What I've observed My other apps that have no entitlements build fine for every teammate. Looking at their embedded profiles, those sign with a wildcard profile (TEAMID.*). This app signs with an explicit profile (TEAMID.com.example.MyApp). If a teammate removes HealthKit and App Groups from all targets, the app builds for them under their own team using the same bundle ID. My understanding (please correct me) App Groups and HealthKit require an explicit App ID, which can only be registered to one team. Since I registered com.example.MyApp first, no other personal team can register the same explicit App ID hence the error. My questions Is that understanding correct — that an entitled (explicit) App ID can only ever belong to a single team? Is there any supported way to keep the same bundle identifier and keep App Groups + HealthKit while teammates build under their own separate personal teams? Or is moving to an Organization account (everyone as members of one shared team) the only way to share an entitled bundle ID across multiple developers? For free personal-team development, is the recommended pattern to give each developer a unique bundle ID + App Group (e.g. via per-developer .xcconfig), keeping entitlements intact? Just want to confirm I'm choosing the right approach before committing to it. Thanks!
Replies
1
Boosts
0
Views
194
Activity
Jun ’26
Detecting External Heart Rate Monitor Availability
I've noticed that the Fitness app on the iPhone can rapidly detect the presence of an Apple Watch or External Heart Rate Monitor (e.g., AirPods Pro 3) so that it can adjust the availability of certain exercise types. Is this done through an API that is public? Can third party fitness apps access similar functionality so users can be pre-alerted to the availability of workout types that require a heart rate sensor of some sort?
Replies
2
Boosts
0
Views
513
Activity
Jun ’26
How long does Apple Watch keep HealthKit data?
I would like to create an Apple Watch only app that queries data such as blood oxygenation, heart varibility, number of steps, energy consumed, and other data of a similar nature recorded over the past month and performs calculations on them. I read from the HealthKit documentation that Apple Watch synchronizes data with iPhone and periodically deletes older data, and that I can get the date from which the data is available with earliestPermittedSampleDate(). Is there a risk that in general, by making queries to retrieve data up to a month old, the data will no longer be available? I need the app to work properly without needing an iPhone.
Replies
5
Boosts
1
Views
2.7k
Activity
Jun ’26
Indoor workout location
In the Fitness app under iOS 26, each workout location is displayed on a small map. For workouts with routes, I can already successfully read out the route and thus also determine the starting point. So that works. For indoor workouts such as yoga or indoor rowing, the exact location is also displayed in the Fitness app. I would now also like to read out this location for these indoor workouts in my app. Does anyone know how to do this?
Replies
1
Boosts
0
Views
488
Activity
May ’26