Implement real-time sync between iOS and Apple Watch apps using WatchConnectivity framework. This replaces reliance on CloudKit which doesn't work reliably in simulators. - Add WatchConnectivityManager to both iOS and Watch targets - Sync workouts, splits, exercises, and logs between devices - Update iOS views to trigger sync on data changes - Add onChange observer to ExerciseView for live progress updates - Configure App Groups for shared container storage - Add Watch app views: WorkoutLogsView, WorkoutLogListView, ExerciseProgressView
32 lines
728 B
Swift
32 lines
728 B
Swift
//
|
|
// WorkoutsApp.swift
|
|
// Workouts
|
|
//
|
|
// Created by rzen on 8/13/25 at 11:10 AM.
|
|
//
|
|
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
|
//
|
|
|
|
|
|
import SwiftUI
|
|
import CoreData
|
|
|
|
@main
|
|
struct WorkoutsApp: App {
|
|
let persistenceController = PersistenceController.shared
|
|
let connectivityManager = WatchConnectivityManager.shared
|
|
|
|
init() {
|
|
// Set up Watch connectivity with Core Data context
|
|
connectivityManager.setViewContext(persistenceController.viewContext)
|
|
}
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
ContentView()
|
|
.environment(\.managedObjectContext, persistenceController.viewContext)
|
|
.environmentObject(connectivityManager)
|
|
}
|
|
}
|
|
}
|