首页 > 解决方案 > 从 Swift Crash 日志中确定源代码行号

问题描述

我刚刚在 TestFlight 测试期间发生了第一次崩溃,并且了解它可以让我知道导致问题的源 swiftui 中的行号。

我已将 .crash 文件放入 Devices & Simulators 中,但看不到任何关于它崩溃的行的任何线索。它让我知道被调用的方法,但不是其中的行号。

是否可以确定它崩溃的线路?

我已经把失败的相关线程跟踪放在下面。

谢谢

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

标签: iosswiftuicrash-reports

解决方案


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))

寻找 atry!并在没有 a 的情况下重写它!


推荐阅读