@main struct SomeApp: App { @Environment(\.scenePhase) private var scenePhase var body: some Scene { WindowGroup { ContentView() }.onChange(of: scenePhase) { (phase) in switch phase { case .active: // The scene is in the foreground and interactive. case .background: // The scene isn’t currently visible in the UI. case .inactive: // The scene is in the foreground but should pause its work. @unknown default: fatalError() } } } }