Xcode 12 beta 4 | UINavigationController `setViewControllers` no longer replaces view controllers

Hi,

In the latest beta (Xcode 12 beta 4) we started noticing that calling setViewControllers on UINavigationController no longer replaces the navigation stack, but instead pushes the replacement view controllers.

e.g.

Code Block swift
let navigationController = UINavigationController(rootViewController: originalViewController)
navigationController.setViewControllers([replacementViewController], animated: true)


In Xcode 12 beta 4 it appears the final result (e.g. inspecting navigationController.viewControllers) yields:

[originalViewController, replacementViewController] in the navigation stack

The expectation is the final result would be:

[replacementViewController] in the navigation stack


Note:
  • This appears to only occur when animated, when using animated: false the behavior works as expected (view controllers get replaced)

Anyone else witnessing this too? Is there anything obvious we're missing? I've filed a feedback for this FB8280522.

Thanks!

Accepted Answer

It appears as of Xcode 12 beta 6 (12A8189n), the issue has been addressed! 🎉

Answers

Someone else is experiencing this here:
https://stackoverflow.com/q/63485966/6457229

It appears that the issue is specific with the setViewControllers function, and does not occur when using functions like popToViewController
It appears as of Xcode 12 beta 6 (12A8189n), the issue has been addressed! 🎉
Unfortunately I have the same strange stack behavior and opened a ticket (FB8626373).
As OP I've noted that the issue appears only when animated, but in my case both popToRootViewController, popViewController and setViewControllers are impacted.
Tested on iOS 14 beta 7.
Problem is still reproducible on iOS 14 GM. In viewDidLoad() stack contains top view controller that was before calling setViewControllers()
Any update on this? Xcode 12 still has the same issue.
Problem is still reproducible on iOS 14, Xcode Version 12.0 (12A7209) with animation set true.
Got the same issue on Xcode Version 12.0.1 , iOS 14. setting animate : false resolves the issue
Still I can reproduce this issue. Here is the sample project to reproduce the issue:
https://github.com/chuganzy/ios-14-uikit-navigation-bug

Xcode 12.3
iOS 14.3

Has anyone here opened radar?