First of all, is this the right place to report a SwiftUI bug? If so, keep reading. Otherwise, apologies for the misuse of this forum, I'd kindly ask where I can post this issue.
I'm testing ScenePhase as an environment variable along with onChange but I don't receive updates. I've created 2 projects from scratch with Xcode Beta choosing the different cycles: UIKit lifecycle: onChange(scenePhase) just gets called on the first run with a wrong value.
SwiftUI lifecycle: onChange(scenePhase) gets successfully called with any change.
struct ContentView: View {
@Environment(\.scenePhase) var scenePhase
var body: some View {
Text("Hello, world!").padding()
.onChange(of: scenePhase) { scenePhase in
print("\(scenePhase)")
}
}
}
The code above prints background on startup. When switching to SwiftUI lifecycle it prints active.
Steps to reproduce
Xcode --> New --> Project --> UKit lifecycle