Xcode 11.2.1 still crash

I am using SwiftUI and had no problem with Xcode 11.1. But it will crash in Xcode 11.2. Just downloaded 11.2.1, and the same problem.


My code is here: first, there is a NavigationView. Inside that NavigationView, there is a TabView.


struct ContentView: View {

let titleStringArray = ["Chat", "Contacts", "Radio","Settings"]

@EnvironmentObject var userData: UserData

@State var currentStatus: Int = 0

var body: some View {

NavigationView {

if userData.idCheckPassed {

TabView {

ChatList()

.tabItem {

Image(systemName: "bubble.left.and.bubble.right.fill")

Text("Chat")

}

.........


Below, is the first tab, ChatList View. Inside this ChatList View, there is a NavigationLink. The target of this NavigationLink (ChatRoomDetail) has a textview. Every time when I try to go back from the ChatRoomDetail, my app crashed.


struct ChatList: View {

@EnvironmentObject var userData: UserData

var body: some View {

List {

ForEach(userData.chatRooms) { item in

NavigationLink(destination: ChatRoomDetail(chatRoom: item)){

Text(item.titleString)

}}}}}



Looks like 11.2.1 did not solve the problem.

Replies

What is the crash log saying ?


Note: there is a new beta 11.2.3 available.

I think you meant an 11.3 Beta? 🙂


11.3b didn't want to show any sims, and had issues using canvas/preview, so...waiting for 11.3b2

Here is the crash log. I really had no clue what I got wrong:


2019-11-15 10:24:27.594873+0800 Playground[7385:707933] *** Assertion failure in -[UINavigationController popToViewController:transition:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3900.12.15/UINavigationController.m:8129

2019-11-15 10:24:27.647984+0800 Playground[7385:707933] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Tried to pop to a view controller that doesn't exist.'

*** First throw call stack:

(

0 CoreFoundation 0x00007fff23c4f02e __exceptionPreprocess + 350

1 libobjc.A.dylib 0x00007fff50b97b20 objc_exception_throw + 48

2 CoreFoundation 0x00007fff23c4eda8 +[NSException raise:format:arguments:] + 88

3 Foundation 0x00007fff256c9b61 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191

4 UIKitCore 0x00007fff4713d9d1 __57-[UINavigationController popToViewController:transition:]_block_invoke + 620

5 UIKitCore 0x00007fff4713d67e -[UINavigationController popToViewController:transition:] + 753

6 SwiftUI 0x00007fff2c1107bd $s7SwiftUI21UIKitNavigationBridgeC3pop33_F345616596EA75D1F4200D7666E5E588LL8animatedySb_tF + 413

7 SwiftUI 0x00007fff2c10fa83 $s7SwiftUI21UIKitNavigationBridgeC20preferencesDidChangeyyAA14PreferenceListVF + 1267

8 SwiftUI 0x00007fff2c09b8fd $s7SwiftUI14_UIHostingViewC20preferencesDidChangeyyF + 477

9 SwiftUI 0x00007fff2c19a5bd $s7SwiftUI9ViewGraphC13updateOutputs2atyAA4TimeV_tF + 221

10 SwiftUI 0x00007fff2c4ed609 $s7SwiftUI16ViewRendererHostPAAE6render8interval17updateDisplayListySd_SbtFyyXEfU_yyXEfU_ + 1001

11 SwiftUI 0x00007fff2c4ed01a $s7SwiftUI16ViewRendererHostPAAE6render8interval17updateDisplayListySd_SbtFyyXEfU_ + 634

12 SwiftUI 0x00007fff2c4e1074 $s7SwiftUI16ViewRendererHostPAAE6render8interval17updateDisplayListySd_SbtF + 436

13 SwiftUI 0x00007fff2c67ce22 $s7SwiftUI14_UIHostingViewC14layoutSubviewsyyF + 226

14 SwiftUI 0x00007fff2c67ce45 $s7SwiftUI14_UIHostingViewC14layoutSubviewsyyFTo + 21

15 UIKitCore 0x00007fff47d34cfd -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2478

16 QuartzCore 0x00007fff2b138d41 -[CALayer layoutSublayers] + 255

17 QuartzCore 0x00007fff2b13ef33 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 517

18 QuartzCore 0x00007fff2b14a86a _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 80

19 QuartzCore 0x00007fff2b0917c8 _ZN2CA7Context18commit_transactionEPNS_11TransactionEd + 324

20 QuartzCore 0x00007fff2b0c6ad1 _ZN2CA11Transaction6commitEv + 643

21 QuartzCore 0x00007fff2b0c743a _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 76

22 CoreFoundation 0x00007fff23bb1617 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23

23 CoreFoundation 0x00007fff23bac0ae __CFRunLoopDoObservers + 430

24 CoreFoundation 0x00007fff23bac72a __CFRunLoopRun + 1514

25 CoreFoundation 0x00007fff23****16 CFRunLoopRunSpecific + 438

26 GraphicsServices 0x00007fff38438bb0 GSEventRunModal + 65

27 UIKitCore 0x00007fff4784fb68 UIApplicationMain + 1621

28 Playground 0x0000000109af3b9b main + 75

29 libdyld.dylib 0x00007fff51a1dc25 start + 1

30 ??? 0x0000000000000001 0x0 + 1

)

libc++abi.dylib: terminating with uncaught exception of type NSException

(lldb)

Clean build folder (option + command + K)

And try to build again.

I work fine by above 2 steps.

(command + shift + K)