iOS16 SwiftUI cannot figure out crash reason

I am getting random crash from time to time while using SwiftUI

but i cannot find a way to get more context into the crash

how to find the root cause?

didn't even get more info while the crash happened while connected to XCode Version 14.1 (14B47b)

OS Version:          iPhone OS 16.1 (20B82)
Release Type:        User
Report Version:      104

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000019a9edeb4
Termination Reason: SIGNAL 5 Trace/BPT trap: 5
Terminating Process: exc handler [45365]

Triggered by Thread:  0

Thread 0 name:   Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   SwiftUI                       	       0x19a9edeb4 0x19a9c3000 + 175796
1   SwiftUI                       	       0x19a9ede98 0x19a9c3000 + 175768
2   SwiftUI                       	       0x19aa02da4 0x19a9c3000 + 261540
3   libswiftCore.dylib            	       0x1910dd138 Slice.index(after:) + 48
4   SwiftUI                       	       0x19abd4d48 0x19a9c3000 + 2170184
5   SwiftUI                       	       0x19ac16594 0x19a9c3000 + 2438548
6   libswiftCore.dylib            	       0x190f29678 BidirectionalCollection.index(_:offsetBy:) + 292
7   SwiftUI                       	       0x19a9edd00 0x19a9c3000 + 175360
8   SwiftUI                       	       0x19be30904 0x19a9c3000 + 21420292
9   SwiftUI                       	       0x19bc2ffa8 0x19a9c3000 + 19320744
10  SwiftUI                       	       0x19b7b1034 0x19a9c3000 + 14606388
11  SwiftUI                       	       0x19b7afc20 0x19a9c3000 + 14601248
12  SwiftUI                       	       0x19b7b21e4 0x19a9c3000 + 14610916
13  UIKitCore                     	       0x1994e57d4 -[UICollectionView _selectItemAtIndexPath:animated:scrollPosition:notifyDelegate:deselectPrevious:performCustomSelectionAction:] + 1060
14  UIKitCore                     	       0x1997314d4 -[UICollectionView touchesEnded:withEvent:] + 480
15  UIKitCore                     	       0x1993e7514 forwardTouchMethod + 284
16  UIKitCore                     	       0x1993e7514 forwardTouchMethod + 284
17  UIKitCore                     	       0x1993e7514 forwardTouchMethod + 284
18  UIKitCore                     	       0x1993e7514 forwardTouchMethod + 284
19  UIKitCore                     	       0x1993185e0 _UIGestureEnvironmentUpdate + 5772
20  UIKitCore                     	       0x199b9ce14 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 288
21  UIKitCore                     	       0x1992dc31c -[UIGestureEnvironment _updateForEvent:window:] + 188
22  UIKitCore                     	       0x1992e0c74 -[UIWindow sendEvent:] + 3268
23  UIKitCore                     	       0x1992dff44 -[UIApplication sendEvent:] + 672
24  UIKitCore                     	       0x1992df600 __dispatchPreprocessedEventFromEventQueue + 7084
25  UIKitCore                     	       0x1993273e4 __processEventQueue + 5632
26  UIKitCore                     	       0x199f790a4 updateCycleEntry + 168
27  UIKitCore                     	       0x199837740 _UIUpdateSequenceRun + 84
28  UIKitCore                     	       0x199e7efd0 schedulerStepScheduledMainSection + 172
29  UIKitCore                     	       0x199e7e19c runloopSourceCallback + 92
30  CoreFoundation                	       0x1970fdf54 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
31  CoreFoundation                	       0x19710a32c __CFRunLoopDoSource0 + 176
32  CoreFoundation                	       0x19708e210 __CFRunLoopDoSources0 + 244
33  CoreFoundation                	       0x1970a3ba8 __CFRunLoopRun + 836
34  CoreFoundation                	       0x1970a8ed4 CFRunLoopRunSpecific + 612
35  GraphicsServices              	       0x1cfb05368 GSEventRunModal + 164
36  UIKitCore                     	       0x1995873d0 -[UIApplication _run] + 888
37  UIKitCore                     	       0x199587034 UIApplicationMain + 340
38  libswiftUIKit.dylib           	       0x19fb73308 UIApplicationMain(_:_:_:_:) + 104
39  Fyzio Klinik Doctor           	       0x10445b2d8 static UIApplicationDelegate.main() + 104
40  Fyzio Klinik Doctor           	       0x10445b260 static AppDelegate.$main() + 44
41  Fyzio Klinik Doctor           	       0x10445b450 main + 28
42  dyld                          	       0x1b5700960 start + 2528

Thread 1:
0   libsystem_pthread.dylib       	       0x1e370eb90 start_wqthread + 0
Post not yet marked as solved Up vote post of min60.com Down vote post of min60.com
653 views

Replies

I encountered a similar error when using List(_:selection:rowContent:) and selecting a row after updating the data source. I used "onTapGesture" for selection to overcome this problem.

List(dataSource) { item in
    HStack {
        Text(item.name)
                    
        Spacer()
    }
    .contentShape(Rectangle())
    .onTapGesture {
        selection = item
    }
}