fix(workoutkit): guard displayName par #available(iOS 18.0)

WorkoutStep.displayName est dispo uniquement à partir d'iOS 18.
Notre fonction tolère iOS 17+ donc Swift refusait la compilation.

Fix : guarde l'assignation par #available(iOS 18.0, *). Sur iOS 17,
l'Apple Watch garde l'affichage natif Apple "Travail"/"Récupération".
Sur iOS 18+, les labels custom Course/Marche/Vélo etc. s'appliquent.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Sylvain Bettinelli
2026-05-13 04:46:08 +00:00
parent e371d0a561
commit 4581852cf5

View File

@@ -163,9 +163,13 @@ public class CoachWorkoutKitPlugin: CAPPlugin, CAPBridgedPlugin {
if let zone = spec.hrZone { if let zone = spec.hrZone {
ws.alert = HeartRateZoneAlert(zone: zone) ws.alert = HeartRateZoneAlert(zone: zone)
} }
// displayName n'est dispo qu'à partir d'iOS 18. Sur iOS 17, on
// garde l'affichage natif Apple "Travail" / "Récupération".
if #available(iOS 18.0, *) {
if let label = spec.label, !label.isEmpty { if let label = spec.label, !label.isEmpty {
ws.displayName = label ws.displayName = label
} }
}
return IntervalStep(spec.isWork ? .work : .recovery, step: ws) return IntervalStep(spec.isWork ? .work : .recovery, step: ws)
} }