从 Swift 崩溃日志中确定源代码行号

Determine source code line No. from Swift Crash log

我刚刚在 TestFlight 测试期间遇到了第一次崩溃,我知道它可以让我知道导致问题的源代码 swiftui 中的第 no 行。

我已将 .crash 文件放入设备和模拟器中,但看不到关于它崩溃的任何线索。它让我知道被调用的方法,但不知道其中的行号。

是否可以确定它崩溃的行?

我已将失败的相关线程跟踪放在下方。

谢谢

Thread 8 name:
Thread 8 Crashed:
0   libswiftCore.dylib              0x000000019c67ccfc _assertionFailure(_:_:file:line:flags:) + 492 (AssertCommon.swift:132)
1   libswiftCore.dylib              0x000000019c67ccfc _assertionFailure(_:_:file:line:flags:) + 492 (AssertCommon.swift:132)
2   libswiftCore.dylib              0x000000019c6df6cc swift_unexpectedError + 436 (ErrorType.swift:188)
3   LocoScene                       0x00000001027f6ed0 closure #1 in MemberAllSpottingSessionsViewModel.getSessionsForPageOne(session_filter:) + 832
4   LocoScene                       0x00000001027fd608 partial apply for closure #1 in MemberAllSpottingSessionsViewModel.getSessionsForPageOne(session_filter:) + 52 (<compiler-generated>:0)
5   LocoScene                       0x0000000102803c94 thunk for @escaping @callee_guaranteed (@guaranteed Data?, @guaranteed NSURLResponse?, @guaranteed Error?) -> () + 132 (<compiler-generated>:0)
6   CFNetwork                       0x000000019909f2ac __40-[__NSURLSessionLocal taskForClassInfo:]_block_invoke + 540 (LocalSession.mm:687)
7   CFNetwork                       0x00000001990b18dc __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 244 (LocalSessionTask.mm:584)
8   libdispatch.dylib               0x000000019867724c _dispatch_call_block_and_release + 32 (init.c:1454)
9   libdispatch.dylib               0x0000000198678db0 _dispatch_client_callout + 20 (object.m:559)
10  libdispatch.dylib               0x000000019868010c _dispatch_lane_serial_drain + 580 (inline_internal.h:2548)
11  libdispatch.dylib               0x0000000198680c90 _dispatch_lane_invoke + 460 (queue.c:3862)
12  libdispatch.dylib               0x000000019868ad78 _dispatch_workloop_worker_thread + 708 (queue.c:6601)
13  libsystem_pthread.dylib         0x00000001e1e9c804 _pthread_wqthread + 276 (pthread.c:2207)
14  libsystem_pthread.dylib         0x00000001e1ea375c start_wqthread + 8

frame#3 告诉我 MemberAllSpottingSessionsViewModel.getSessionsForPageOne() 中有一个闭包调用 swift_unexpectedError(ErrorType.swift,第 188 行)

我用谷歌搜索 'ErrorType.swift libswiftcore' 并找到了 https://github.com/apple/swift/blob/main/stdlib/public/core/ErrorType.swift#L188,这告诉我

'try!' expression unexpectedly raised an error: \(String(reflecting: error))

寻找 try! 并在没有 !

的情况下重写它