I have already searched for a lot of information about this issue. Many people have encountered it with UISplitViewController or on iPadOS, but I am experiencing this problem on iOS 18. It does occasionally occur on iOS 17, but it definitely happens on iOS 18. The error messages are as follow:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Layout requested for visible navigation bar, <UINavigationBar: 0x14a6b3c00; frame = (0 44; 375 44); autoresize = W; tintColor = UIExtendedGrayColorSpace 1 1; layer = <CALayer: 0x3026a9da0>> delegate=0x14a674600 standardAppearance=0x300d1d0a0 scrollEdgeAppearance=0x300d1cf50, when the top item belongs to a different navigation bar. topItem = <UINavigationItem: 0x14a7f8780> style=navigator leftBarButtonItems=0x302423b40, navigation bar = <UINavigationBar: 0x14adcb700; frame = (0 0; 375 44); autoresize = W; tintColor = UIExtendedGrayColorSpace 1 1; layer = <CALayer: 0x302680940>> delegate=0x14ade8c00 standardAppearance=0x300d7a7d0 scrollEdgeAppearance=0x300d7a610, possibly from a client attempt to nest wrapped navigation controllers.' *** First throw call stack: (0x193f3a08c 0x191242698 0x19330a8fc 0x196939290 0x1966847b4 0x1967cdc88 0x1959ba6d8 0x1966c86bc 0x196769d50 0x1967cae58 0x196771f28 0x196b0fcb8 0x196764800 0x196684280 0x1959ba6d8 0x1959ba264 0x195a12edc 0x195990560 0x1968295f0 0x193f1c218 0x193f0a4c0 0x193f09b84 0x193f09368 0x1e00fc1c4 0x196a569b0 0x196b04d54 0x10462b1fc 0x1ba144734) libc++abi: terminating due to uncaught exception of type NSException
I am sure about the process on iOS 17, first I use UINavigationController.present(UINavigationController()) and then call keyWindow.rootViewController = UINavigationController(), it crashes. So I can dismiss the presentedViewController before assign keyWindow.rootViewController. However, on iOS 18, the app crash when launch.