Last active
July 26, 2024 17:26
-
-
Save nathan-fiscaletti/b58b642f78a4f60274e3be703e230140 to your computer and use it in GitHub Desktop.
A tool for symbolicating iOS crash reports.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CRASH=$1 | |
APP=$2 | |
ARCH=$3 | |
OUTPUT=$4 | |
# This script will fully symbolicate an iOS Crash Report | |
# Usage: ./symbolicate.sh mycrash.crash MyApp.app arch64 output.crash | |
# | |
# If you do not supply an output file the script will simply print the symbolicated script to STDOUT. | |
function main() { | |
if [ ! "$#" -gt 3 ]; then | |
echo "Usage: $0 <crash> <app> <arch> [output]" | |
exit | |
fi | |
if [ ! -z $OUTPUT ]; then | |
OUTPUT=$(pwd)/$OUTPUT | |
fi | |
pushd "$(dirname "$APP")" > /dev/null | |
NUMOFLINES=$(wc -l < "$CRASH") | |
CURLINENUM=1 | |
if [ ! -z $OUTPUT ]; then | |
echo "Symbolicating to $OUTPUT..." | |
echo -n '' > $OUTPUT | |
fi | |
while IFS='' read -r line || [[ -n "$line" ]]; do | |
keys=$(echo $line | grep -oE -e '0x([a-z]|[0-9])+\s0x([a-z]|[0-9])+') | |
if [ ! -z "$keys" ]; then | |
symbolicated=$(symbolicate $keys); | |
fi | |
if [ ! -z $OUTPUT ]; then | |
reportProgress $CURLINENUM $NUMOFLINES | |
echo ${line/$keys/$symbolicated} >> $OUTPUT | |
else | |
echo ${line/$keys/$symbolicated} | |
fi | |
CURLINENUM=$(awk "BEGIN {print $CURLINENUM+1}") | |
done < "$CRASH" | |
printf "\n" | |
popd > /dev/null | |
} | |
function symbolicate() { | |
appname=$(echo $APP | grep -oE -e '([^\/.]+)\.') | |
echo $(xcrun atos -o "$APP/${appname/./}" -arch $ARCH -l $2 $1) | |
} | |
function reportProgress() { | |
PROGRESS=$(awk "BEGIN {printf \"%.0f\n\", ($1/$2)*100}") | |
printf '\r\033[KProgress: ' | |
printf "$PROGRESS" | |
echo -n "%" | |
} | |
main $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, I just all files to a folder with no spaces. This was more just for your reference if you were curious. I didn't put the full file path as the output variable, instead I CD'd into the folder with the executable file and output was just a single file name in the same folder.