State change not updating view when compiled in `Release` config

Hey there,

i'm currently a little stumped, I have the following view:

struct SwiftUITestView: View {

    @State private var hasAppeared = false

    var body: some View {
        Group {
            Text("HasAppeared: \(hasAppeared ? "Y" : "N")")
        }
        .onAppear {
            print("appears")
            hasAppeared = true
        }
    }
}

which works as expected when built using Debug configuration.
But when I build it in release mode, the print("appears") will fire, but the text never changes, i.e. the view never updates.
What could be optimised away in release-mode that stops my SwiftUI views from rerendering?

PS:
This would not happen in a plain SwiftUI app. Only when used in a UIKit app where I host the SwiftUI screen in a UIHostingController:

        let hostVC = UIHostingController(rootView: SwiftUITestView())
        hostVC.view.translatesAutoresizingMaskIntoConstraints = false

        addChild(hostVC)
        view.insertSubview(hostVC.view, at: 0)

        NSLayoutConstraint.activate([
            hostVC.view.leftAnchor.constraint(equalTo: view.leftAnchor),
            hostVC.view.rightAnchor.constraint(equalTo: view.rightAnchor),
            hostVC.view.topAnchor.constraint(equalTo: view.topAnchor),
            hostVC.view.bottomAnchor.constraint(equalTo: view.bottomAnchor)
        ])

        hostVC.didMove(toParent: self)

So, it turns out this was caused by an old build setting apps used to set. Found the solution on Stackoverflow.
Reflection Metadata Level was set to None for Release builds in the Build Settings of this 4 year old project.