This question is a follow-up of https://developer.apple.com/forums/thread/695853 I need to save a workout with a route from a locked iPhone. I've tried many different ways of saving it since more than one year but I still struggle to find a code which works when the phone is locked. My current code is : let healthStore = HKHealthStore() let workoutConfiguration = HKWorkoutConfiguration() workoutConfiguration.activityType = .running let builder = HKWorkoutBuilder(healthStore: healthStore, configuration: workoutConfiguration, device: .local()) try await builder.beginCollection(at: workout.start) guard let quantityType = HKQuantityType.quantityType(forIdentifier: .activeEnergyBurned) else { ... } let totalEnergyBurnedSample = HKCumulativeQuantitySample(type: quantityType, quantity: HKQuantity(unit: HKUnit.kilocalorie(), doubleValue: totalEnergyBurned), start: workout.start, end: workout.end) try await builder.addSamples([totalEnergyBurnedSample]) if let route = builder.seriesBuilder(for: .worko