一般來說,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>>顯示包內(nèi)容>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 //這種一般是設(shè)備性能太差(內(nèi)存、CPU),被系統(tǒng)給終結(jié)的
- Exception Subtype: WAKEUPS // 系統(tǒng)奔潰分類
-
Exception Message: (Limit 150/sec) Observed 346/sec over 300 secs // 異常信息,相當于系統(tǒng)
redline -
Exception Note: NON-FATAL CONDITION (this is NOT a crash) // 異常備注,
this is NOT a crash,區(qū)別于常見的內(nèi)存操作錯誤造成的崩潰,這是系統(tǒng)主動terminate的 -
Triggered by Thread: 34 // 觸發(fā)異常/崩潰的線程,很關(guān)鍵,拿到Thread號,然后去找對應(yīng)thread的堆棧信息,就能很快定位到奔潰原因。
奔潰線程堆棧
6. 注意事項
- .dSYM的UUID要和.crash的對應(yīng)上,否則會報錯
No symbolic information found - 查看.dSYM的UUID:
dwarfdump --uuid xxx.dSYM -
查看.crash的UUID:
.crash文件 - 指定Xcode環(huán)境變量:
export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer",然后echo $DEVELOPER_DIR看一下是否已經(jīng)設(shè)置成功了。- 注意
export DEVELOPER_DIR這種方式是臨時的,也就是關(guān)閉Terminal后再打開并解析.crash文件時,要重新執(zhí)行這條命令。 - 要想“一勞永逸”,就在
~/根目錄下新建.bash_profile,然后把上面這條命令加進去,然后執(zhí)行source .bash_profile,重啟Terminal,再echo $DEVELOPER_DIR看看是否成功。
- 注意
- 重要事情說三遍:
每次打包后,一定要備份.dSYM,最好是有命名規(guī)范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"

