iOS | 崩溃日志.ips/.crash文件解析
2019-06-15 本文已影响0人
清無
一般来说,Mac无法直接打开.ips文件,所以获取到.ips文件时,将后缀改为.crash,然后就可以直接浏览了。
dSYM files store the debug symbols for your app.
dSYM files will likely change each time your app is compiled (probably every single time due to date stamping), and have nothing to do with the project settings.
Ideally, your dSYM file shouldn't be tracked in your git repo. Like other binaries that change on building, it's not useful to keep them in source control.
dSYMs and executables have an embedded UUID which matches. So every time a build is done will cause both to get a new UUID. The consequence is that symbolication only works if the UUID of the binary that caused a crash matches the UUID of the dSYM that is used for symbolication.
1. 获取symbolicatecrash工具
路径:/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/symbolicatecrash
2. 获取.dSYM文件
.ipa的
路径:Xcode>Window>Organizer>Archives>xxx>Show in Finder>xxx.xcarchive>>显示包内容>xxx.app.dSYM
.framework的
路径:xxx.project>Products>xxx.framework>Show in Finder>Release-iphoneos>xxx.dSYM
3. 获取.crash文件
Xcode>Window>Devices and Simulators>选择已连接的真机>View Device Logs>xxxApp>右键导出.crash文件
借助iTunes获取.ips/.crash文件
- OS X:
~/Library/Logs/CrashReporter/MobileDevice/(your iPhone’s name)/(your app name)
- Windows XP:
C:\Documents and Settings\Application Data\Apple computer\Logs\CrashReporter\(your iPhone’s name)\(your app name)
- Windows Vista/7+:
C:\Users\AppData\Roaming\Apple computer\Logs\CrashReporter\MobileDevice\(your iPhone’s name)\(your app name)
4. 解析.crash文件
终端命令:./symbolicatecrash xxx.crash xxx.dSYM > crash.log
5. 分析.crash文件
- Exception Type: EXC_RESOURCE //这种一般是设备性能太差(内存、CPU),被系统给终结的
- Exception Subtype: WAKEUPS // 系统奔溃分类
-
Exception Message: (Limit 150/sec) Observed 346/sec over 300 secs // 异常信息,相当于系统
redline
-
Exception Note: NON-FATAL CONDITION (this is NOT a crash) // 异常备注,
this is NOT a crash
,区别于常见的内存操作错误造成的崩溃,这是系统主动terminate的 -
Triggered by Thread: 34 // 触发异常/崩溃的线程,很关键,拿到Thread号,然后去找对应thread的堆栈信息,就能很快定位到奔溃原因。
奔溃线程堆栈
6. 注意事项
- .dSYM的UUID要和.crash的对应上,否则会报错
No symbolic information found
- 查看.dSYM的UUID:
dwarfdump --uuid xxx.dSYM
-
查看.crash的UUID:
.crash文件 - 指定Xcode环境变量:
export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"
,然后echo $DEVELOPER_DIR
看一下是否已经设置成功了。- 注意
export DEVELOPER_DIR
这种方式是临时的,也就是关闭Terminal后再打开并解析.crash文件时,要重新执行这条命令。 - 要想“一劳永逸”,就在
~/
根目录下新建.bash_profile
,然后把上面这条命令加进去,然后执行source .bash_profile
,重启Terminal,再echo $DEVELOPER_DIR
看看是否成功。
- 注意
- 重要事情说三遍:
每次打包后,一定要备份.dSYM,最好是有命名规范app_version_buid.dSYM,例如:WCRLiveCore_1.1.33_18.dSYM
- 自动导出.dSYM文件:
cp -r "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework.dSYM" "${HOME}/Desktop/${PROJECT_NAME}_$(date +"%Y%m%d_%H%M%S").framework.dSYM"