Skip to content

Instantly share code, notes, and snippets.

@nonameplum
Last active February 20, 2021 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nonameplum/484f6a69487f912d89428a9253a14dac to your computer and use it in GitHub Desktop.
Save nonameplum/484f6a69487f912d89428a9253a14dac to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Fool'n'Lazy-Proof iOS .crash Symbolication
#
# Just run this script on a folder with your `.ipa`, the corresponding `.dSYM`,
# and (1+) `.crash` files. Will output symbolicated `sym-*.crash`es for you.
#
# Copyright (c) 2016 Ferran Poveda (@fbeeper)
# Provided under MIT License (MIT): http://choosealicense.com/licenses/mit/
#
# Extended by Lukasz Sliwinski to check equality of the build's UUID with the crash logs
#
function checkForRequiredFileOfType()
{
count=`find $1 -print -quit 2> /dev/null | wc -l | awk '{print \$1}'`
if [[ $count > 0 ]]; then
echo "Found a $1 file"
else
echo "Missing a $1 file! Need *.ipa + *.dSYM + *.crash files."
exit
fi
}
function checkForRequiredFiles()
{
checkForRequiredFileOfType "*.ipa"
checkForRequiredFileOfType "*.dSYM"
checkForRequiredFileOfType "*.crash"
}
# Define location of symbolicatecrash binary (defaults to Xcode location, but can be defined on params)
symbolicatecrash=${symbolicatecrash:-/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/symbolicatecrash}
# Let's make sure you haven't forgotten any file
checkForRequiredFiles
# Extract .ipa and define where the binary is (assuming it has the same name)
ipa=`find *.ipa -print -quit`
bsdtar -xf "$ipa" -s'|[^/]*/||'
app=`find *.app -print -quit`
app="$app$/${app%.*}"
dSYM=`find *.dSYM -print -quit`
uuid=`dwarfdump -u $dSYM | perl -ne 'print $1 if /UUID: (.*) \(arm64\)/s' | cut -c 1-42 | tr -d '-' | awk '{ print tolower($0) }'`
echo ""
echo "Build UUDD: $uuid"
echo ""
# Symbolicate all .crash files
export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"
for i in *.crash; do
if [[ ! $i == sym* ]]; then # Skips previous output files from this script
build_name=`grep '{"app_name":' $i | perl -ne 'print $1 if /{"app_name":"([^"]+)","/s' | awk '{ print($0) }'`
crashFileUuid=`grep --after-context=1000 "Binary Images:" $i | grep "$build_name arm64" | perl -ne 'print $1 if /.*<(.*)>/s' | awk '{ print($0) }'`
if [ "$uuid" == "$crashFileUuid" ]; then
"$symbolicatecrash" "$i" "$app" > "sym-$i"
echo "✅ Symbolicated $i"
else
echo "❌ skipped $i (crash UUID [$crashFileUuid] do not match build's UUID: [$uuid]"
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment