Skip to content

Instantly share code, notes, and snippets.

@nathan-fiscaletti
Last active September 24, 2023 21:44
Show Gist options
  • Save nathan-fiscaletti/b58b642f78a4f60274e3be703e230140 to your computer and use it in GitHub Desktop.
Save nathan-fiscaletti/b58b642f78a4f60274e3be703e230140 to your computer and use it in GitHub Desktop.
A tool for symbolicating iOS crash reports.
#!/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 $@
@diyontheweb
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment