Warm tip: This article is reproduced from serverfault.com, please click

Determine source code line No. from Swift Crash log

发布于 2020-11-27 13:53:35

I've just had my first crash during TestFlight testing and understand that it can let me know the line no in the source swiftui which is causing the issue.

I've dropped the .crash file into Devices & Simulators but can't see any clue as to which line it's crashed. It lets me know the method which was called but not the line number within it.

Is it possible to determine the line at which it crashed?

I've put below the relevant thread trace which failed.

Thanks

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

Questioner
Houdi
Viewed
0
mr. fixit 2020-11-28 09:44:53

frame#3 tells me there's a closure in MemberAllSpottingSessionsViewModel.getSessionsForPageOne() that's calling swift_unexpectedError (ErrorType.swift, line 188)

i googled 'ErrorType.swift libswiftcore' and found https://github.com/apple/swift/blob/main/stdlib/public/core/ErrorType.swift#L188, which told me

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

look for a try! and rewrite it without a !