Keep A Watch Workout Useful When The Phone Disconnects
The phone loses contact halfway through a run. That should change the phone’s status label, not end the workout on the watch.
A useful companion architecture separates the watch’s workout lifecycle from the transport that happens to display its progress elsewhere. The watch keeps collecting and saving through HealthKit; the phone can be temporarily out of date.
Keep the workout owner on the watch
Apple’s workout-session guidance covers the session, builder, save lifecycle, and recovery of an active session. Those responsibilities belong to the device running the workout. A communication error is not a HealthKit stop command.
Persist the app-specific information that HealthKit cannot infer: the workout’s app ID, plan selection, current interval, and the sequence number used for companion updates. Use the recovered HealthKit session and builder after a supported recovery; do not create a second workout merely because your custom screen model was recreated.
This article adds a small display mirror to that lifecycle. It does not replace HealthKit’s workout mirroring APIs or reproduce the complete workout manager. If your app already uses session mirroring, reuse that mechanism for its supported responsibilities and keep custom companion data narrow.
Send a snapshot that stands on its own
A phone that misses updates two through ten should still understand update eleven. Include the current state instead of a stream of instructions like “add one second.”
import Foundation
struct WorkoutSnapshot: Codable, Equatable, Sendable {
enum Phase: String, Codable, Sendable {
case running, paused, ended
}
var version = 1
let workoutID: UUID
let sequence: Int
let elapsedSeconds: Double
let phase: Phase
}
The watch assigns a stable ID when starting the workout and advances a persisted sequence when producing a new snapshot. Elapsed time should come from the workout’s authoritative timeline, including pauses. Do not make successful message delivery responsible for advancing it.
The sequence only has meaning inside that workout. A new workout gets a new ID. If the watch process restarts, continue the existing sequence from durable state rather than starting again at zero under the old ID.
Reject an old snapshot before it changes the screen
Here is the receiving policy for a phone that has already selected a workout:
struct WorkoutMirror {
let selectedWorkoutID: UUID
private(set) var latest: WorkoutSnapshot?
mutating func accept(_ update: WorkoutSnapshot) -> Bool {
guard update.version == 1,
update.workoutID == selectedWorkoutID,
update.sequence >= 0,
update.elapsedSeconds.isFinite,
update.elapsedSeconds >= 0,
update.sequence > (latest?.sequence ?? -1)
else { return false }
latest = update
return true
}
}
An old running snapshot can no longer overwrite a newer ended snapshot. Repeated delivery of the same sequence becomes a no-op. A snapshot for another workout cannot silently switch the screen’s selection.
Selecting the current workout is a separate reconciliation step, not “accept whichever random ID arrived last.” Reconcile against your known workout records and account context. Persist the last accepted snapshot if this ordering guarantee needs to survive a phone-app restart; the small struct above is only an in-memory reducer.
Use the transport that matches the data
WCSession.isReachable describes availability for live messaging. It is not a workout phase and not a requirement for every WatchConnectivity transfer API.
For replaceable companion state, updateApplicationContext can send the latest dictionary when the counterpart is not currently reachable. The WCSession must be activated. A new context replaces the previous one, which fits a latest-state display:
import WatchConnectivity
@MainActor
func publish(_ snapshot: WorkoutSnapshot, to session: WCSession) throws {
guard session.activationState == .activated else { return }
try session.updateApplicationContext([
"workoutSnapshot": try JSONEncoder().encode(snapshot)
])
}
The encoded Data is a property-list-compatible value. This helper does not establish the WCSession delegate or activate it; the connectivity owner does that once. Keep the latest snapshot locally and publish it when activation completes. If updating the context throws, retain it for a later attempt.
A successful call means the context was accepted for transfer, not that the phone has displayed it. Do not show “synced” on that evidence alone. Keep the payload compact and publish meaningful changes or a reasonable cadence instead of serializing every sensor sample.
An End Workout command is different. It needs an explicit command ID, acknowledgment, and duplicate handling against the authoritative session. Do not send it through a replaceable snapshot channel and assume it will be executed exactly once.
Make stale information understandable
The phone can show the last received elapsed time with “Waiting for watch.” Do not turn a silent connection into an invented paused or ended state. If the UI extrapolates a timer, stop or clearly mark that estimate when freshness is uncertain.
Keep Start, Pause, Resume, and End usable on the watch. Confirm the workout’s save result locally, even if the phone never reconnects during the session. A completed workout should not depend on a phone-side acknowledgment merely to remain saved.
September 2026 verification: the fixture passed duplicate, out-of-order, wrong-workout and Codable round-trip checks. The WatchConnectivity adapter type-checked for iOS 17 and watchOS 10 using the version 27 SDKs. Physical pairing, HealthKit collection, crash recovery, and background transfer timing were not exercised.