[UIViewController willMoveToParentViewController:] provides an incorrect navStack when popping a view controller in iPadOS 18.2

The Apple documentation for [UIViewController willMoveToParentViewController:] states,

Called just before the view controller is added or removed from a container view controller.

Hence, the view controller being popped should appear at the top of the navStack when willMoveToParentViewController: is called.

In iPadOS 16 and 17 the view controller being popped appears at the top of the navStack when willMoveToParentViewController: is called.

In iPadOS 18 the view controller being popped has already been (incorrectly) removed from the navStack. We confirmed this bug using iPadOS 18.2 as well as 18.0.

Our app relies upon the contents of the navStack within willMoveToParentViewController: to track the user's location within a folder hierarchy.

Our app works smoothly on iPadOS 16 and 17. Conversely, our customers running iPadOS 18 have lost client data and corrupted their data folders as a result of this bug! These customers are angry -- not surprisingly, some have asked for refunds and submitted negative app reviews.

Why doesn't willMoveToParentViewController: provide the correct navStack in iPadOS 18.2?

This bug also appears when running on macOS Sequoia 15.2 as an Apple-silicon Mac App (Designed for iPad) built with Xcode 16.2.

We filed a bug since this occurs on the latest available version of iPadOS (18.2) and macOS (15.2) when built with the latest Xcode (16.2): https://feedbackassistant.apple.com/feedback/16136753

[UIViewController willMoveToParentViewController:] provides an incorrect navStack when popping a view controller in iPadOS 18.2
 
 
Q