From 678b5a41d0ba94d7ffeca82987058428329835f5 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Mon, 25 May 2026 20:37:03 +0200 Subject: [PATCH] chore: logs os_log bout-en-bout (watch sendSample + iPhone liveSample) + hook AUTOSIM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Logger unified (capturable via simctl) côté watch (envoi) et iPhone (réception) pour valider le pont WCSession. Hook AUTOSIM (env var) démarre le mode test au lancement, pour validation automatisée sur simulateur. Pont prouvé E2E sur sim pair iPhone+Watch : HR identiques watch->iPhone. Co-Authored-By: Claude Opus 4.7 (1M context) --- ios/App/App/CoachLiveBridge.swift | 5 +++++ ios/App/CoachWatch/ConnectivityManager.swift | 5 +++++ ios/App/CoachWatch/ContentView.swift | 17 +++++++++++++---- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/ios/App/App/CoachLiveBridge.swift b/ios/App/App/CoachLiveBridge.swift index 7a1c4e0..2d35013 100644 --- a/ios/App/App/CoachLiveBridge.swift +++ b/ios/App/App/CoachLiveBridge.swift @@ -14,6 +14,9 @@ import Foundation import Capacitor import WatchConnectivity +import os + +private let liveLog = Logger(subsystem: "ch.hypnotruck.coach", category: "live") @objc(CoachLiveBridgePlugin) public class CoachLiveBridgePlugin: CAPPlugin, CAPBridgedPlugin { @@ -46,6 +49,8 @@ public class CoachLiveBridgePlugin: CAPPlugin, CAPBridgedPlugin { } private func emit(_ sample: [String: Any]) { + let hr = (sample["heartRate"] as? Double) ?? -1 + liveLog.info("liveSample reçu de la Watch hr=\(hr, privacy: .public)") CAPLog.print("⚡️ CoachLiveBridge: liveSample reçu de la Watch -> \(sample)") DispatchQueue.main.async { [weak self] in self?.notifyListeners("liveSample", data: sample) diff --git a/ios/App/CoachWatch/ConnectivityManager.swift b/ios/App/CoachWatch/ConnectivityManager.swift index 6e32f3f..e1dd9a6 100644 --- a/ios/App/CoachWatch/ConnectivityManager.swift +++ b/ios/App/CoachWatch/ConnectivityManager.swift @@ -1,5 +1,8 @@ import Foundation import WatchConnectivity +import os + +private let connLog = Logger(subsystem: "ch.hypnotruck.coach.watchkitapp", category: "connectivity") /// Envoie les samples de séance vers l'iPhone. /// - `sendMessage` quand l'iPhone est joignable (temps réel) @@ -23,6 +26,8 @@ final class ConnectivityManager: NSObject, ObservableObject { func sendSample(_ payload: [String: Any]) { queue.async { let session = WCSession.default + let hr = (payload["heartRate"] as? Double) ?? -1 + connLog.info("sendSample activated=\(session.activationState == .activated, privacy: .public) reachable=\(session.isReachable, privacy: .public) hr=\(hr, privacy: .public)") guard session.activationState == .activated else { self.buffer.append(payload) return diff --git a/ios/App/CoachWatch/ContentView.swift b/ios/App/CoachWatch/ContentView.swift index b3088d3..fa46a19 100644 --- a/ios/App/CoachWatch/ContentView.swift +++ b/ios/App/CoachWatch/ContentView.swift @@ -5,10 +5,19 @@ struct ContentView: View { @EnvironmentObject private var workout: WorkoutManager var body: some View { - if workout.isRunning { - LiveWorkoutView() - } else { - ActivityPickerView() + Group { + if workout.isRunning { + LiveWorkoutView() + } else { + ActivityPickerView() + } + } + .task { + // Déclenchement auto du mode test (validation simulateur) : + // SIMCTL_CHILD_AUTOSIM=1 xcrun simctl launch … + if ProcessInfo.processInfo.environment["AUTOSIM"] == "1" { + workout.startSimulation() + } } } }