<!--
{
  "availability" : [
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKWorkoutSession/startMirroringToCompanionDevice(completion:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKWorkoutSession(im)startMirroringToCompanionDeviceWithCompletion:"
  },
  "title" : "startMirroringToCompanionDevice(completion:)"
}
-->

# startMirroringToCompanionDevice(completion:)

Starts mirroring the workout session to the companion iOS device.

```
func startMirroringToCompanionDevice(completion: @escaping @Sendable (Bool, (any Error)?) -> Void)
```

## Parameters

`completion`

A block that the system calls when the start request is complete. The system sets the following parameters:

- `success`: A Boolean value that indicates whether the system successfully started mirroring the session.
- `error`: If `success` is <doc://com.apple.documentation/documentation/Swift/false>, this contains an object that describes the error. Otherwise, it’s `nil`.

## Discussion

Call this method in your watchOS app to start a mirrored workout session on the companion iOS app. If your iOS app isn’t running, the system launches it in the background. The iOS companion app must assign a completion handler to its HealthKit Store’s [`workoutSessionMirroringStartHandler`](/documentation/HealthKit/HKHealthStore/workoutSessionMirroringStartHandler) property to process the incoming session.

> Important:
> This method fails if you call it on a workout session that ended.

```swift
let configuration = HKWorkoutConfiguration()
configuration.activityType = .running
configuration.locationType = .outdoor

let session: HKWorkoutSession
do {
    session = try HKWorkoutSession(healthStore: store,
                                   configuration: configuration)
} catch {
    // Handle failure here.
    fatalError("*** An error occurred: \(error.localizedDescription) ***")
}

let builder = session.associatedWorkoutBuilder()

let source = HKLiveWorkoutDataSource(healthStore: store,
                                     workoutConfiguration: configuration)

source.enableCollection(for: HKQuantityType(.stepCount), predicate: nil)
builder.dataSource = source

session.delegate = self
builder.delegate = self

self.session = session
self.builder = builder

let start = Date()

// Start the mirrored session on the companion iPhone.
do {
    try await session.startMirroringToCompanionDevice()
}
catch {
    fatalError("*** Unable to start the mirrored workout: \(error.localizedDescription) ***")
}


// Start the workout session.
session.startActivity(with: start)

do {
    try await builder.beginCollection(at: start)
} catch {
    fatalError("*** An error occurred while starting the workout: \(error.localizedDescription) ***")
}
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)