---
title: HKWorkoutBuilder
framework: healthkit
role: symbol
role_heading: Class
path: healthkit/hkworkoutbuilder
---

# HKWorkoutBuilder

A builder object that incrementally constructs a workout.

## Declaration

```swift
class HKWorkoutBuilder
```

## Mentioned in

Accessing workout zone data

## Overview

Overview Incrementally collect samples and events associated with a workout. When the workout ends, call finishWorkout(completion:) to create an HKWorkout sample and save it to the HealthKit store. For watchOS, use an HKWorkoutSession and an HKLiveWorkoutBuilder instead.

## Topics

### Creating the builder

- [init(healthStore:configuration:device:)](healthkit/hkworkoutbuilder/init(healthstore:configuration:device:).md)
- [device](healthkit/hkworkoutbuilder/device.md)
- [workoutConfiguration](healthkit/hkworkoutbuilder/workoutconfiguration.md)

### Starting the workout

- [beginCollection(withStart:completion:)](healthkit/hkworkoutbuilder/begincollection(withstart:completion:).md)
- [startDate](healthkit/hkworkoutbuilder/startdate.md)
- [elapsedTime(at:)](healthkit/hkworkoutbuilder/elapsedtime(at:).md)

### Associating samples with the workout

- [add(_:completion:)](healthkit/hkworkoutbuilder/add(_:completion:).md)
- [seriesBuilder(for:)](healthkit/hkworkoutbuilder/seriesbuilder(for:).md)
- [statistics(for:)](healthkit/hkworkoutbuilder/statistics(for:).md)

### Adding metadata to the workout

- [addMetadata(_:completion:)](healthkit/hkworkoutbuilder/addmetadata(_:completion:).md)
- [metadata](healthkit/hkworkoutbuilder/metadata.md)

### Adding events to the workout

- [addWorkoutEvents(_:completion:)](healthkit/hkworkoutbuilder/addworkoutevents(_:completion:).md)
- [workoutEvents](healthkit/hkworkoutbuilder/workoutevents.md)

### Managing workout activities

- [addWorkoutActivity(_:completion:)](healthkit/hkworkoutbuilder/addworkoutactivity(_:completion:).md)
- [updateActivity(uuid:adding:completion:)](healthkit/hkworkoutbuilder/updateactivity(uuid:adding:completion:).md)
- [updateActivity(uuid:end:completion:)](healthkit/hkworkoutbuilder/updateactivity(uuid:end:completion:).md)
- [workoutActivities](healthkit/hkworkoutbuilder/workoutactivities.md)

### Ending the workout

- [endCollection(withEnd:completion:)](healthkit/hkworkoutbuilder/endcollection(withend:completion:).md)
- [endDate](healthkit/hkworkoutbuilder/enddate.md)
- [finishWorkout(completion:)](healthkit/hkworkoutbuilder/finishworkout(completion:).md)
- [discardWorkout()](healthkit/hkworkoutbuilder/discardworkout().md)

### Accessing workout statistics

- [allStatistics](healthkit/hkworkoutbuilder/allstatistics.md)

### Configuring zone data

- [setCustomZoneConfiguration(_:for:)](healthkit/hkworkoutbuilder/setcustomzoneconfiguration(_:for:).md)
- [zoneConfiguration(for:)](healthkit/hkworkoutbuilder/zoneconfiguration(for:).md)

### Instance Methods

- [zoneGroup(for:)](healthkit/hkworkoutbuilder/zonegroup(for:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Inherited By

- [HKLiveWorkoutBuilder](healthkit/hkliveworkoutbuilder.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Samples

- [Adding samples to a workout](healthkit/adding-samples-to-a-workout.md)
- [Accessing condensed workout samples](healthkit/accessing-condensed-workout-samples.md)
- [Dividing a HealthKit workout into activities](healthkit/dividing-a-healthkit-workout-into-activities.md)
- [HKWorkout](healthkit/hkworkout.md)
- [HKWorkoutActivity](healthkit/hkworkoutactivity.md)
- [HKWorkoutType](healthkit/hkworkouttype.md)
- [HKWorkoutTypeIdentifier](healthkit/hkworkouttypeidentifier.md)
- [HKWorkoutActivityType](healthkit/hkworkoutactivitytype.md)
- [HKWorkoutSessionType](healthkit/hkworkoutsessiontype.md)
- [HKWorkoutEvent](healthkit/hkworkoutevent.md)
