参考文章 https://juejin.cn/post/6844903598011187213
自动化脚本,保证dsym和crash文件在一个目录下即可。
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
symbolToolPath="./symbolicatecrash"
crashPath=""
dSYMPath=""
if [ ! -f "$symbolToolPath" ]
then
symbolToolPath="/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/symbolicatecrash"
echo "symbolicatecrash工具的路径是为:"$symbolToolPath
if [ -f "$symbolToolPath" ]
then
echo "symbolicatecrash工具存在(文件为普通文件)"
else
echo "无法找到symbolicatecrash工具"
fi
fi
function findFile(){
crashPath=$(find . -name "*.crash")
}
if [ -n "$1" ]
then
crashPath=$1
echo "已传入crash文件路径:$crashPath"
else
findFile
echo "搜索同级目录下crash文件...."
fi
if [ ! -f "$crashPath" ]
then
echo "搜索失败,无法找到crash文件"
exit
else
echo "【搜索成功】找到的Crash路径:$crashPath"
fi
dSYMPath=$(find . -name "*.dSYM" -print)
echo "【搜索成功】找到的符号表路径:$dSYMPath"
if [ ! -d $dSYMPath ]
then
echo "无法找到符号表dSYM文件"
exit
fi
#找crashPath的UUID
crashContent=$(cat $crashPath)
crashUuid=$(echo "$crashContent" | grep -o 'UUID:\s\+\w\+-\w\+-\w\+-\w\+-\w\+')
crashUuid=$(echo "$crashUuid" | sed 's/^UUID:[[:space:]]*//')
#找dsym的UUID
dsymContent=$(dwarfdump --uuid $dSYMPath)
dsymUuid=$(echo "$dsymContent" | grep -o 'UUID:\s\+\w\+-\w\+-\w\+-\w\+-\w\+')
dsymUuid=$(echo "$dsymUuid" | sed 's/^UUID:[[:space:]]*//')
if [ "$crashUuid" = "$dsymUuid" ]
then
echo "两个文件的UUID相等,可以正常解析"
else
echo "dSYM UUID:$dsymUuid"
echo "Crash UUID:$crashUuid"
echo "Warning:⚠️两个UUID不相等"
fi
# ./symbolicatecrash ./*.crash ./*.app.dSYM > symbol.crash
"$symbolToolPath" $crashPath $dSYMPath > symbol.log