Last active
December 10, 2020 06:59
-
-
Save twissmueller/90bed7f22f3a760dc09e0cfe434f3ebd to your computer and use it in GitHub Desktop.
A template for an application based on SwiftUI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import os.log | |
@main | |
struct MyApp: App { | |
private let logger = Logger(subsystem: "bundleId", category: "classname") | |
@Environment(\.scenePhase) private var scenePhase | |
var body: some Scene { | |
WindowGroup { | |
ContentView() | |
} | |
.onChange(of: scenePhase) { (newScenePhase) in | |
switch newScenePhase { | |
case .active: | |
logger.debug("Scene entered active phase") | |
case .inactive: | |
logger.debug("Scene entered inactive phase") | |
case .background: | |
logger.debug("Scene entered background phase") | |
@unknown default: | |
logger.debug("Scene entered an undetermined phase") | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment