Navigation issue in Xcode 16 beta 7

I've got an iOS app and a main view with a list with a search field. When I click on a list item navigation link takes me to another view through navigation destination modifier. I can go back to the main list view. Now, consider this scenario:

  • Click in the search field (you do not have to type there anything)
  • Click any item on the list

This all works fine when I build the app with Xcode 15.4 and I can get back to the main list. But if I build the app using Xcode 16 beta 7 the destination view is shown twice (the destination view is shown and then moved again to the same view) and I cannot back to the main view at all. I can go back one view only.

Could it be a bug in Xcode? Was do you think about that?

A code snippet might help.

I do not see any beta 7. last available (AFAIK) is beta 6: 16A5230g

iOS 18 beta 7, Xcode beta 6 (a slip-up)

An update: This issue occurs only in Debug mode and seems to be related to environment macros in the view. I had the following line defined:

@Environment(\.scenePhase) private var scenePhase

However, the variable wasn't even used. After removing that line, the problem disappeared.

I tried to create some code to reproduce the issue, but I couldn't get the issue to happen.

Navigation issue in Xcode 16 beta 7
 
 
Q