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.