I've been experiencing a "silent" app crash for quite some time now. It's fairly repeatable and happens when transitioning from one screen to another in SwiftUI:
ZStack {
switch(router.currentScreen) {
case .screenA:
ScreenA()
case .screenB:
ScreenB()
}
}
.animation(.easeOut(duration: 0.5), value: router.currentScreen)
*Note - it doesn't happen EVERY time when going to screen A to screen B. But when the app does crash, it's always when going from screen A to B, so the issue isn't with the code above - I'm just including that for context. The problem is that there's no breakpoint hit in Xcode, no stack trace, and no output in the console. If I'm running while attached to the debugger I'll get this error:
Lost connection to the debugger. Domain: IDEDebugSessionErrorDomain Code: 22
User Info: {
DVTErrorCreationDateKey = "2024-03-25 19:04:52 +0000";
IDERunOperationFailingWorker = DBGLLDBLauncher;
}
If I'm not connected to the debugger, the app just dies like I said. I'm unable to find any record of the crash anywhere so I have no idea why or what code is causing it.
What I've tried:
- Setting the "All Objective-C Exceptions" breakpoint (never gets tripped)
- Setting the "All Runtime Issues" breakpoint (never gets tripped)
- Xcode -> Devices and Simulators -> Open Recent Logs (no relevant logs)
- Xcode -> Devices and Simulators -> Open Console (empty for my device)
- Checked Crashlytics. Says I'm 100% crash-free.
- Monitoring Memory in the Xcode Debug Navigator. It goes up from around 60 to around 120 MB at this point, but that doesn't seem like enough to cause a crash.
- Product -> Analyze ("Succeeded", but no other info)
- Instruments -> Leaks (no leaks detected)
- Texting Tim Cook (no response)
What else can I do to find out why my app is crashing???
You might want to try the Address Sanitizer. This can often help identify these strange crashes. You can find it by clicking your scheme on the top bar, and selecting "Edit Scheme".
More information about how to use it can be found here: https://developer.apple.com/documentation/xcode/diagnosing-memory-thread-and-crash-issues-early