A builder object that constructs a workout incrementally based on live data from an active workout session.


class HKLiveWorkoutBuilder : HKWorkoutBuilder


Use a live workout builder to create an HKWorkout sample during an active HKWorkoutSession. For complete instructions on running workout sessions on Apple Watch, see Running Workout Sessions.


Configuring a Live Workout Buidler.

var dataSource: HKLiveWorkoutDataSource?

A data source that provides live data from a workout session automatically.

var workoutSession: HKWorkoutSession?

The workout session created by the data source and associated with this builder.

Monitoring and Controlling the Workout

var delegate: HKLiveWorkoutBuilderDelegate?

The live builder’s delegate.

protocol HKLiveWorkoutBuilderDelegate

A protocol for monitoring live workout builders.

var shouldCollectWorkoutEvents: Bool

A Boolean value that determines whether the workout builder automatically adds events generated by the workout session.

Accessing Data

var elapsedTime: TimeInterval

The elapsed time for the workout based on the builder's current contents, including pauses.


Inherits From

Conforms To

See Also


Running Workout Sessions

Track a workout on Apple Watch.

SpeedySloth: Creating a Workout

Use the Workout Builder API to start, stop, and to save workouts on Apple Watch.

class HKWorkoutSession

A session that tracks the user’s workout on Apple Watch.

class HKWorkoutConfiguration

An object that contains configuration information about a workout session.

enum HKWorkoutSessionState

A workout session’s state.

class HKLiveWorkoutDataSource

A data source that automatically provides live data from an active workout session.