import SwiftUI import os private let logger = Logger(subsystem: "com.overrun", category: "app") @main struct WorkoutEditorApp: App { var body: some Scene { WindowGroup { WorkoutListView() .onOpenURL { url in if url.scheme == "overrun" { StravaManager.shared.handleCallback(url) } } .task { do { try await HealthKitManager.shared.requestAuthorization() logger.notice("Auth succeeded") await HealthKitManager.shared.loadWorkouts() HealthKitManager.shared.startObservingWorkouts() logger.notice("Loaded \(HealthKitManager.shared.loadedWorkouts.count) workouts") #if DEBUG if HealthKitManager.shared.loadedWorkouts.count < 200 { logger.notice("Fewer than 200 workouts, resetting sample data...") try await HealthKitManager.shared.deleteAllWorkouts() try await HealthKitManager.shared.insertSampleWorkouts() await HealthKitManager.shared.loadWorkouts() logger.notice("After insert: \(HealthKitManager.shared.loadedWorkouts.count) workouts") } #endif } catch { logger.error("HealthKit error: \(error)") } } } } }