OPTION 1
I use this Run Script to automate the process
if [ "${CONFIGURATION}" = "Release" ]; then
GOOGLESERVICE_INFO_PLIST=GoogleService-Info.plist
GOOGLESERVICE_INFO_FILE="/path/to/GoogleService-Info.plist"
# (Usually "${PROJECT_DIR}/Runner/GoogleService-Info.plist")
if [ -f "$GOOGLESERVICE_INFO_FILE" ]; then
echo "Using GoogleService-Info.plist from ${GOOGLESERVICE_INFO_FILE}"
# Get GOOGLE_APP_ID from GoogleService-Info.plist file
APP_ID="$(grep -A1 GOOGLE_APP_ID ${GOOGLESERVICE_INFO_FILE} | tail -n1 | sed -e 's/.*\<string\>\(.*\)\<\/string\>/\1/')"
# Run scripts to upload dSYMs to Firebase crashlytics
"$PODS_ROOT/FirebaseCrashlytics/run" -ai "${APP_ID}"
"$PODS_ROOT/FirebaseCrashlytics/upload-symbols" --build-phase --validate -ai "${APP_ID}"
"$PODS_ROOT/FirebaseCrashlytics/upload-symbols" --build-phase -ai "${APP_ID}"
"$PODS_ROOT/FirebaseCrashlytics/upload-symbols" -gsp "${GOOGLESERVICE_INFO_FILE}" -p ios "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}" -ai "${APP_ID}"
echo "Successfully uploaded dSYMs to Firebase Crashlytics!"
else
echo "GoogleService-Info.plist not found in ${GOOGLESERVICE_INFO_FILE}"
fi
fi
OPTION 2
However, if you're like me and you have build schemes for your app (like Release-dev, Release-prod, Release-beta); then do this instead,
Ensure you have setup your build schemes correctly, else the next steps will probably not work for you. PS: I use this medium post.
Ensure you have GoogleService-Info.plist for each scheme in separate folders;
IMPORTANT: Your folder structure should look something like this:
config
|
|
--- dev -- GoogleService-Info.plist
|
|
--- beta -- GoogleService-Info.plist
|
|
--- prod -- GoogleService-Info.plist
- Ensure you have enabled dSYM for Release builds under: Targets -> Runner -> Build Settings -> Build Options -> Debug Information Format. Should be set to
DWARF with dSYM File
Then add a Run Script with name [firebase_crashlytics] Upload dSYMs to Firebase Crashlytics
(or whatever).
Copy & paste the below in the script section:
if [ "${CONFIGURATION}" = "Release" ]; then
environment="default"
# Set the current build environment / scheme
if [[ $CONFIGURATION =~ -([^-]*)$ ]]; then
environment=${BASH_REMATCH[1]}
fi
GOOGLESERVICE_INFO_PLIST=GoogleService-Info.plist
# And here you can see why that folder structure is important.
GOOGLESERVICE_INFO_FILE=${PROJECT_DIR}/config/${environment}/${GOOGLESERVICE_INFO_PLIST}
if [ -f "$GOOGLESERVICE_INFO_FILE" ]; then
echo "Using GoogleService-Info.plist from ${GOOGLESERVICE_INFO_FILE}"
# Get GOOGLE_APP_ID from GoogleService-Info.plist file
APP_ID="$(grep -A1 GOOGLE_APP_ID ${GOOGLESERVICE_INFO_FILE} | tail -n1 | sed -e 's/.*\<string\>\(.*\)\<\/string\>/\1/')"
# Run scripts to upload dSYMs to Firebase crashlytics
"${PODS_ROOT}/FirebaseCrashlytics/run" -ai "${APP_ID}"
"$PODS_ROOT/FirebaseCrashlytics/upload-symbols" --build-phase --validate -ai "${APP_ID}"
"$PODS_ROOT/FirebaseCrashlytics/upload-symbols" --build-phase -ai "${APP_ID}"
"${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" -gsp "${GOOGLESERVICE_INFO_FILE}" -p ios "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}" -ai "${APP_ID}"
echo "Successfully uploaded dSYMs to Firebase Crashlytics!"
else
echo "GoogleService-Info.plist not found in ${GOOGLESERVICE_INFO_FILE}"
fi
fi
- In the Input Files section, add the paths for the locations of the following files:
- The location of your project's dSYM files:
${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}
- The location of your project's built Info.plist file:
$(SRCROOT)/$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)
See the Firebase docs for more info
That's all!
the Runner.app.dSYM.zip
inside theios
directory. It is generated by theflutter build ios
command for release builds, assuming Crashlytics was setup correctly. – Anemochore