ios - 从 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
解决方案
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 的情况下重写它!
推荐阅读
- timezone - 如何防止 mariadb 在重启时重置时区?
- postgresql - PostgreSQL - tcp_keepalives_idle - 需要解释
- asp.net-mvc - 如何在 ASP.NET MVC 项目中更好地实现二级登录
- ios - 带有 UITableView 的 UITableViewCell 未显示
- angular - 无法在 Safari 中运行量角器测试
- javascript - 如何在 JavaScript 中编写两个对象之间的碰撞和反应
- javascript - Javascript:如何使变量“私有”仅用于当前的递归层?
- android - 单个事件实时数据多次发出空值将给出正确的结果
- javascript - 如何解决错误,当页面中的“onChange”未在单选按钮组件中使用时
- node.js - 如何从 Mongodb 获取数据