Coupe of things here.
I'll assume you've set scenePhase using:
@Environment(\.scenePhase) private var scenePhase
If so, you don't need phase in; you can simply refer to scenePhase, i.e.:
.onChange(of: scenePhase) {
if(scenePhase == .active) {
Secondly, scenePhase does not equal UIApplication.shared.applicationState. An application can be active and a scene can be inactive. That's why you're seeing your debug output.
The app goes into the background after a few seconds, to allow you to complete any processing you needed to do - writing to a file, or database, whatever. The scene will go into the background before the app.
Do you really need to know if the app state has changed, or the scene? It seems you're mixing two things here.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: