Expected a popover view,found(null) crash

The relevant code is roughly as follows:

Under what circumstances will this error be triggered? I simulated self(DemoViewController) as nil and nav as nil, but the relevant error report cannot be triggered.

Could you please tell me about this crash(Crash info: Expected a popover view,found(null))?

Under what circumstances does it occur?

class DemoViewController: UIViewController {

  func show() {
        let exitVC = UIViewController()
        let nav = UINavigationController(rootViewController: exitVC)
        let exitButton = UIButton(frame: CGRect(x: 50, y: 50, width: 100, height: 100))
        nav.modalPresentationStyle = .popover
        nav.popoverPresentationController?.permittedArrowDirections = .down
        nav.popoverPresentationController?.sourceView = exitButton
        nav.popoverPresentationController?.sourceRect = exitButton.bounds
        nav.popoverPresentationController?.delegate = exitVC
         
        // sounds crash at this function.
        present(nav, animated: true, completion: nil)
  }

}

I get the same crash on iPadOS 17 too. Do you have any good solution?

Expected a popover view,found(null) crash
 
 
Q