iOS 18 beta - .onAppear in NavSplitView creates an infinite loop

Bug in iOS 18 beta? .onAppear of a NavSplitView-DetailView is called repeatedly after dismissing the view. The app gets unresponsive and can only be killed and cold-restartet.

What happens:

I update a Binding property in .onAppear of a NavigationSplitView-DetailView.

Whenever I leave the DetailView going back to the ListView (the NavSplitView’s first column), the DetailView's .onAppear get’s triggered in an endless loop. This blocks the main thread and freezes the app.

This behaviour is only appearing in iOS 18 betas (simulators and devices) and not on iOS 17.x releases.

If I remove the code updating the Binding, the .onAppear loop does not happen.

Another way of triggering the same unexpected behaviour is by updating an OberservedObject appState.shared singleton, e.g. by a timer.

Has anybody come across this type of behaviour? Is this a know change of iOS 18 behaviour or a bug even?

It's possible you're doing something wrong in your code, but without seeing that code it's unlikely we'll be able to help.

Can you provide a small reproducible example?

Yeah, sure! Thank you for commenting! I thought it might be a know "wrong" coding pattern or even a iOS 18 beta bug, as it is not showing up in iOS 17.x.

Will try to create a small reproducible example and post it here.

iOS 18 beta - .onAppear in NavSplitView creates an infinite loop
 
 
Q