I'm testing out my code that starts an HKWorkoutSession
collects samples and ends then saves the workout using the old HKWorkoutConfiguration
API (not the new HKWorkoutBuilder
API)....my understanding is that the previous API should still work.
However when testing in the watch simulator, starting and stopping a workout using Xcode 10 Beta 4 and 5, I noticed that I am able to start a workout and query samples, however when I call healthStore.stop
there is a 5 or 6 second delay until the workout ends?
// Create workout configuration
let workoutConfiguration = HKWorkoutConfiguration()
workoutConfiguration.activityType = .running
workoutConfiguration.locationType = .outdoor
do {
workoutSession = try HKWorkoutSession(configuration: workoutConfiguration)
workoutSession?.delegate = self
} catch {
fatalError(error.localizedDescription)
}
func start(_ workoutSession: HKWorkoutSession) {
healthStore.start(workoutSession)
}
func end(_ workoutSession: HKWorkoutSession) {
healthStore.end(workoutSession)
}
Update 9/20/18: I filed a radar, it was marked as dup....as of Xcode 10 GM release this bug is still present. Confirmed this does NOT happen on device, only simulator.