iPad parent child refreshing issue - onAppear is NOT getting called every single time.

This code works well in iPhone but not on iPad. In iPad, although the "Selected topic" text in TopicDetailView changes with every list selection, **onAppear is NOT getting called every single time. **

I need to do some backend operation on onAppear here. What am I doing wrong here? At first it looks like working fine, but go backward tapping in list, random tapping, every time, "selected topic " changes, but NOT every time onAppear gets called. I must have the onAppear called every time to run backend operations. I have latest devices, simulators, Xcode as of today. I cannot use NavigationStack as I need to support ios15.0 onwards

import SwiftUI
  
struct TopicsView: View {
    var topics = ["Topic1","Topic2","Topic3"]
    var body: some View {
        NavigationView {
            List(topics, id:\.self ) { topic in
                        NavigationLink(
                            destination: TopicDetailView(topic: topic).id(UUID())
                          ) {
                            Text(topic)
                          }
                    }
        }
    }

}


struct TopicDetailView: View {
     var topic: String
 
     var body: some View  //body{
    {
        VStack{
            Text("Selected topic \(topic)")
         }
         .onAppear(){
            print("on appear on topic \(topic)")
        }
         .onChange(of: topic){ v in
             print("on change to topic \(v)")
         }
    }
}


struct ContentView: View {
    var body: some View {
        TopicsView()
    }
    
    
 }

I was just trying to force UI redraw with .id(UUID()) but with it or without it , it behaves the same erratic way.

I tested with Xcode 14.2, iPad simulator (iOS 16.2) and it works as expected.

on appear on topic Topic1
on appear on topic Topic2
on appear on topic Topic3
on appear on topic Topic1
on appear on topic Topic2
on appear on topic Topic3

Take care that onAppear is only called when view is loaded. May be in your case, view is not offloaded and reloaded ?

I tested 20 times, on simulator, both in Portrait and landscape. onAppear always called.

Please explain exactly how you get the error, and which versions you use. On simulator or device ?

For the meaning: offloaded means the view is offloaded from view hierarchy and will be reloaded after.

Am on Xcode 15.0

**DOES NOT WORK IN FOLLOWING **

Simulators: Model iPad Pro (12.9")iOS 17.0 both 3rd gen and 6th gen

Devices: iPad Model MQDx2LL/A 10.5" 17.0

It is easily reproducible if you start from top to bottom and then go bottom to top in list selection, then it starts skipping calling onAppear randomly.

**WORKS PERFECTLY WELL IN **

Simulator: Model iPad Pro 11" 1st gen 15.0

I am unable to find iOS16.x simulators in my Xcode, all show up only with 15.0. or 17.0

iPad parent child refreshing issue - onAppear is NOT getting called every single time.
 
 
Q