Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwiftUI view hierarchy and view identity debug

I have a master list -> detail view UI. Looks fine.

But when I show a detail view of one of the list element, the view sometimes supriously goes back to the list.

The master list can be updated in the background and when this happen, the list is re-ordered. I think that what is causing the "going back". According to this SO question SwiftUI Navigation View goes back in hierarchy and to this WWDC video, it seems my views identity are not constant.

How can I read and debug the view hierarchy (I mean SwiftUI view, not the corresponding UIViews) and their identity ?

Edit: changed the title to be more in line with the question.

like image 322
AirXygène Avatar asked Nov 23 '25 17:11

AirXygène


1 Answers

You can use:

    var body: some View {
#if DEBUG
        let _ = Self._printChanges()
#endif

in your body definition to find out why this view is redrawn.

like image 55
Marc Avatar answered Nov 26 '25 13:11

Marc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!