From 35cf2b53ce30a79e936a49bf4b104e4751e053af Mon Sep 17 00:00:00 2001 From: Sylvain Bettinelli Date: Mon, 11 May 2026 16:42:27 +0000 Subject: [PATCH] fix(plugin): lazy HKHealthStore + load() override pour debug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hypothèse : HKHealthStore() à l'init de classe peut causer un échec silencieux qui empêche Capacitor d'enregistrer le plugin. Lazy init. Aussi : public override func load() avec NSLog pour qu'on voie dans les logs natifs si Capacitor charge bien la classe au boot. --- ios/App/App/CoachHealthRoute.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ios/App/App/CoachHealthRoute.swift b/ios/App/App/CoachHealthRoute.swift index ee59697..ffa7967 100644 --- a/ios/App/App/CoachHealthRoute.swift +++ b/ios/App/App/CoachHealthRoute.swift @@ -11,6 +11,7 @@ // // r.available = bool (false si pas de route associée, pas d'autorisation, etc.) import Foundation +import UIKit import Capacitor import HealthKit import CoreLocation @@ -25,7 +26,12 @@ public class CoachHealthRoutePlugin: CAPPlugin, CAPBridgedPlugin { CAPPluginMethod(name: "getRoute", returnType: CAPPluginReturnPromise), ] - private let store = HKHealthStore() + private lazy var store = HKHealthStore() + + public override func load() { + NSLog("[CoachHealthRoute] plugin loaded (iOS \(UIDevice.current.systemVersion))") + super.load() + } @objc func isAvailable(_ call: CAPPluginCall) { call.resolve(["available": HKHealthStore.isHealthDataAvailable()])