---
title: "addWorkoutActivity(_:completion:)"
framework: healthkit
role: symbol
role_heading: Instance Method
path: "healthkit/hkworkoutbuilder/addworkoutactivity(_:completion:)"
---

# addWorkoutActivity(_:completion:)

Adds a workout activity to the workout builder.

## Declaration

```swift
func addWorkoutActivity(_ workoutActivity: HKWorkoutActivity, completion: @escaping @Sendable (Bool, (any Error)?) -> Void)
```

```swift
func addWorkoutActivity(_ workoutActivity: HKWorkoutActivity) async throws
```

## Parameters

- `workoutActivity`: The workout activity to add.
- `completion`: A callback handler that the system calls after adding the workout activity. The system calls the callback handler on an anonymous background queue. The callback handler takes the following parameters:

## Discussion

Discussion You can call this method repeatedly to incrementally add activities to the builder. Calling this method after calling finishWorkout(completion:) fails with an error. If you add an HKWorkoutActivity object that doesn’t have an endDate, you can set the end date by calling updateActivity(uuid:end:completion:).

## See Also

### Managing workout activities

- [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)
