To capture iOS application crash information, I implemented mechanisms using Apple's NSSetUncaughtExceptionHandler alongside signal handling. While this approach captures most crash scenarios, it may fall short when diagnosing more complex failures.
Alternative Approaches
1. Utilizing Third-party Monitoring Platforms
Well-known platforms offer robust crash reporting capabilities:
- Bugly
- Firebase Crashlytics
- Umeng Analytics
- TingYun Performence Monitor
2. Open-source Crash Reporting Libraries
Popular open-source solutions include:
- KSCrash
- PLCrashReporter
Ultimately, I chose TLCrashReporter for integration. Below documents the process of parsing crash logs using dSYM files.
dSYM-based Crash Log Parsing
1. Parsed Crash Log Format
A successfully symbolicated log reveals detailed information including sepcific line numbers and function names where crashes occurred. Raw stack traces, however, remain difficult to interpret without processing.
2. Manual Stack Trace Symbolication
Xcode provides built-in tools for crash log analysis:
Locate the symbolicatecrash utility using terminal command:
find /Applications/Xcode.app -name symbolicatecrash -type f
This returns the tool path, for example:
/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/Library/PrivateFrameworks/DVTFoundation.framework/symbolicatecrash
Create a working directory containing:
- The symbolicatecrash executable
- Raw crash file (e.g., 1.crash)
- Corresponding dSYM file (e.g., 1.dSYM)
Execute symbolication command:
./symbolicatecrash /Users/mac/Desktop/crash/1.crash /Users/mac/Desktop/crash/1.dSYM > Control_symbol.crash
Potential warning message:
symbolicatecrash is deprecated; it will be removed in future releases of Xcode ⚠️
Error: "DEVELOPER_DIR" is not defined at ./symbolicatecrash line 75.
Resolve by setting environment variable:
export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"
Re-run the symbolication command to generate properly parsed crash report with detailed failure information.
Troubleshootign Common Issues
1. Missing dSYM Files After Archiving
Two Xcode build settings require verification:
(1) Confirm Project -> Build Settings -> Generate Debug Symbols is set to YES. When configured as NO, debug symbol generation is disabled, preventing dSYM file creation.
(2) With Generate Debug Symbols enabled, verify Project -> Build Settings -> Debug Information Format is configured as "DWARF with dSYM File". Setting this to "DWARF" alone will not produce dSYM files regardless of other configurations.
2. No Symbolic Information Found Error
This error occurs due to UUID mismatches between components:
Each xx.app file, xx.app.dSYM file, and crash report contains unique UUID identifiers. Successful symbolication requires matching UUIDs across all three components.
Verify UUID consistency using these commands:
(1) Check xx.app UUID:
dwarfdump --uuid xx.app/xx
(2) Check xx.app.dSYM UUID:
dwarfdump --uuid xx.app.dSYM
(3) Locate crash file UUID within the "Binary Images:" section, contained within angle brackets <>.