From 33b88cb8f04d33272600b2f49771a7f0a84efe51 Mon Sep 17 00:00:00 2001 From: rzen Date: Sat, 19 Jul 2025 17:43:32 -0400 Subject: [PATCH] wip --- Workouts.xcodeproj/project.pbxproj | 8 ++++---- Workouts/WorkoutsApp.swift | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Workouts.xcodeproj/project.pbxproj b/Workouts.xcodeproj/project.pbxproj index b901763..946e3e8 100644 --- a/Workouts.xcodeproj/project.pbxproj +++ b/Workouts.xcodeproj/project.pbxproj @@ -263,8 +263,8 @@ INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -294,8 +294,8 @@ INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/Workouts/WorkoutsApp.swift b/Workouts/WorkoutsApp.swift index 0b589c2..39764d6 100644 --- a/Workouts/WorkoutsApp.swift +++ b/Workouts/WorkoutsApp.swift @@ -12,9 +12,12 @@ import SwiftUI import SwiftData import CloudKit import CoreData +import UIKit @main struct WorkoutsApp: App { + // Control whether to prevent device auto-lock + @State private var preventAutoLock: Bool = true let container: ModelContainer @State private var cloudKitObserver: NSObjectProtocol? @@ -23,6 +26,9 @@ struct WorkoutsApp: App { // Set up CloudKit notification observation setupCloudKitObservation() + + // Disable screen auto-lock + UIApplication.shared.isIdleTimerDisabled = true } private func setupCloudKitObservation() { @@ -61,6 +67,14 @@ struct WorkoutsApp: App { var body: some Scene { WindowGroup { ContentView() + .onAppear { + // Ensure auto-lock is disabled when app appears + UIApplication.shared.isIdleTimerDisabled = preventAutoLock + } + .onDisappear { + // Re-enable auto-lock when app disappears + UIApplication.shared.isIdleTimerDisabled = false + } } .modelContainer(container) }