vovaklh
vovaklh

Reputation: 119

Flutter: Upload dsym symbols to Firebase crashlytics with flavors

I want to upload dsym symbols from Flutter app with multiple flavors. Each GoogleService-Info is places inside config/flavor_name folder. What script should I add to "Build Phases" to upload dsym to Firebase Crashlytics?

Try script from another thread but it seems it doesn't work

Upvotes: 5

Views: 3375

Answers (2)

Juho Torkkeli
Juho Torkkeli

Reputation: 111

Here is a better script. Instead of cat and grep, it uses PlistBuddy, a built-in Mac tool. Also, don't forget step 5. from here: https://firebase.google.com/docs/crashlytics/get-deobfuscated-reports?platform=flutter

environment="default"

# Get environment name
if [[ $CONFIGURATION =~ -([^-]*)$ ]]; then
environment=${BASH_REMATCH[1]}
fi

echo $environment

# Name and path of the resource we're reading
GOOGLESERVICE_INFO_PLIST=GoogleService-Info.plist
GOOGLESERVICE_INFO_FILE=${PROJECT_DIR}/config/${environment}/${GOOGLESERVICE_INFO_PLIST}

# Make sure GoogleService-Info.plist exists
if [ ! -f $GOOGLESERVICE_INFO_FILE ]
then
echo "No GoogleService-Info.plist found. Please ensure it's in the proper directory."
exit 1
fi

# Get app id
APP_ID=$(/usr/libexec/PlistBuddy -c "Print :GOOGLE_APP_ID" "${GOOGLESERVICE_INFO_FILE}")

echo $APP_ID

$PODS_ROOT/FirebaseCrashlytics/upload-symbols --build-phase --validate -ai ${APP_ID}
$PODS_ROOT/FirebaseCrashlytics/upload-symbols --build-phase -ai ${APP_ID}

Upvotes: 11

vovaklh
vovaklh

Reputation: 119

I found a script

environment="default"

if [[ $CONFIGURATION =~ -([^-]*)$ ]]; then
environment=${BASH_REMATCH[1]}
fi

GOOGLESERVICE_INFO_PLIST=GoogleService-Info.plist
GOOGLESERVICE_INFO_FILE=${PROJECT_DIR}/config/${environment}/${GOOGLESERVICE_INFO_PLIST}

if [ ! -f $GOOGLESERVICE_INFO_FILE ]
then
echo "No GoogleService-Info.plist found. Please ensure it's in the proper directory."
exit 1
fi

google_app_id=$(cat $GOOGLESERVICE_INFO_FILE | grep -oEi '\d:\d*?:ios:[[:alnum:]]*')

echo $google_app_id

$PODS_ROOT/FirebaseCrashlytics/upload-symbols --build-phase --validate -ai $google_app_id
$PODS_ROOT/FirebaseCrashlytics/upload-symbols --build-phase  -ai $google_app_id

Upvotes: 3

Related Questions