Post

Replies

Boosts

Views

Created

Healthkit HKWorkoutSession state not transitioning
Im building a workout app to track swimming workouts for watchos 11. Triggering .prepare() on my HKWorkoutSession does not change the session state HKWorkoutSessionState. Below is my prepare function which should transition the session state to HKWorkoutSessionStatePrepared. Nothing is thrown in the delegates, the state just wont change? I have tried erasing, restarting, use another version of xcode and another simulator runtime. func prepare() { guard self.session == nil else { fatalError("Session already exist") } // Configure Workout Type let config = HKWorkoutConfiguration() config.activityType = .swimming config.swimmingLocationType = .openWater config.locationType = .outdoor self.Workoutconfig = config // Create Session do { guard store.authorizationStatus(for: .workoutType()) == .sharingAuthorized else { fatalError("Lack of permission to start workout") } let session = try HKWorkoutSession(healthStore: store, configuration: config) self.session = session self.builder = session.associatedWorkoutBuilder() Logger.diveController.info("Successfully created workout session") builder?.dataSource = HKLiveWorkoutDataSource(healthStore: store, workoutConfiguration: config) self.session?.delegate = self self.builder?.delegate = self if self.session == nil { fatalError("No workout session created") } if self.builder == nil { fatalError("No workout builder created") } self.session?.prepare() logger.debug("Session Started at: \(self.session?.startDate ?? Date())") logger.debug("Session State: \(self.session?.state.description ?? "")") if self.session?.state != .prepared { reset() fatalError("Failed To Prepare") } } catch { Logger.diveController.error("Error starting workout session: \(error.localizedDescription)") } }
1
0
949
Oct ’24
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
21
1w
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
40
1w