ScenePhase Change Not Firing

Viewed 29

For some reason, I'm not getting the .onChange(scenePhase) firing. No matter which View I place the modifier on there's no output:

import SwiftUI

struct TabViewDashboard: View {
    @Environment(\.scenePhase) var scenePhase
    
    var body: some View {
        ZStack {
            VStack {
//more code here....
        }
        .onChange(of: scenePhase) { newPhase in
            debugPrint("NewPhase: ", newPhase as Any)
        }
        .onAppear {
            // code here
        }
        .onDisappear {
            // function here
        }
    }
}

I'm not getting any debug output for any scene changes.

I know this View is being called from a UIKit->SwiftUI UIHostingController. Could this be the reason I'm getting no output?

Min. OS: iOS 14.

0 Answers
Related