How to upload dsyms files which developed with Flutter?
Asked Answered
A

7

33

I am developing one Cross-platform app with flutter support. I Integrated firebase Crashlytics for crash reports. before I need to check report one error message comes

Upload 1 missing dSYM required to process 4 crashes

for that, I tried firebase docs

Get deobfuscated crash reports

also, I followed steps to build iOS Archive with flutter

Preparing an iOS App for Release

Still, There is the same issue on firebase portal

Upload 1 missing dSYM required to process 4 crashes

I tried this many times but still not done yet.

If someone has Idea then please help me to fix this issue.

Thanks, Community

Abstraction answered 16/4, 2019 at 13:55 Comment(4)
You should find the Runner.app.dSYM.zip inside the ios directory. It is generated by the flutter build ios command for release builds, assuming Crashlytics was setup correctly.Anemochore
I also tried this but not done.Abstraction
How are you generating release packages?Anemochore
using On the command line, follow these steps in your application directory: Run flutter build ios to create a release build (flutter build defaults to --release). To ensure that Xcode refreshes the release mode configuration, close and re-open your Xcode workspace. For Xcode 8.3 and later, this step is not required.Abstraction
R
39

Let your Xcode upload it automatically when you run/build your app.

I. Open Xcode > Targets > MyProjectName > Build phases

Add two scripts (using + sign) consisting of each of these

  1. "${PODS_ROOT}/FirebaseCrashlytics/run"

  2. "${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" -gsp "${PROJECT_DIR}/MyProjectName/GoogleService-Info.plist" -p ios "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"

Important: Make sure to replace MyProjectName with your project name but leave rest as it is.

II. Also make sure to check these options in Targets > MyProjectName > Build settings

Set Debug information format to DWARF with dSYM file

III. Visuals enter image description here enter image description here enter image description here enter image description here

Reareace answered 7/4, 2021 at 7:5 Comment(9)
I did exact same config as you but I still got the warning in firebase console... Any idea what can possibly go wrong?Calcareous
NB: it's "${PROJECT_DIR}/Runner/GoogleService-Info.plist" and not "${PROJECT_DIR}/MyProjectName/GoogleService-Info.plist" (your screenshot is good)Calcareous
@Calcareous The screenshot is an example of the project name "Runner" so that makes it relevant.Reareace
oh I'm learning something, I never did an iOS project without Flutter so I was thinking that "Runner" was like the "app" folder in Android and that it cannot have another name ^^Calcareous
This no longer works, since you initialize firebase with the flutterfire CLI. Since no GoogleService-Info.plist is used anymore, I tried using exchanging -gsp "[Path to file]" with -ai "[App ID]". But i still get the following error: error: Could not get GOOGLE_APP_ID in Google Services file from build environment. Does anyone know how I can fix this?Sportive
Okay, I figured it out myself. You have to add -ai "[App ID]" to the first script as wellSportive
Note that the generated "GoogleService-Info.plist" should also be manually added to xCode (click on Runner, then File -> Add files to "Runner") or you'll get "Could not get GOOGLE_APP_ID in Google Services file from build environment".Jonathonjonati
-ai "[App ID]" is the only thing that was needed in my case. refer: firebase.google.com/docs/crashlytics/…Ribaudo
For multiple flavors, what we need to do for fetching GoogleService-Info.plist file for different environment.Heretic
L
23

When preparing my app for release I take these steps to export, upload, and get the dSYM's:

  1. In terminal I run 'flutter build ios --release'
  2. Open the iOS project in xCode and switch the device to 'Generic iOS Device'
  3. From the top menu Product>Archive
  4. Once finished the Organizer window will show your archived build. You can also manually open this window from Window>Organizer
  5. Choose the build you want to upload to iTunes Connect and hit Distribute App and follow the process
  6. After upload is complete right click on the build in the organizer window and click 'Show in Finder'
  7. You should see an archive file in finder, right-click it and click 'Show Package Contents'.
  8. Inside there should be a folder called dSYM that you can zip and send wherever you need
Loris answered 31/10, 2019 at 15:9 Comment(2)
Right, but how do you know exactly which of them is missing? The name in the Firebase warning is some kind of UUID, but the filenames in the dSYM-folder are normal filenames of plugins etc?Escarp
That's right. I did it and it's work. but this is the manual method. Thanks a lotsManuscript
S
9

you can use Fastlane to automate also this as part of release process. here's an example that can go into your Fastfile

platform :ios do
  desc "Upload symbols to Crashlytics"
  lane :toCrashlytics do
    upload_symbols_to_crashlytics
  end
end

then you can run fastlane ios toCrashlytics to run it.

see this link for more details.

Stiffen answered 13/5, 2020 at 7:24 Comment(3)
The best way! Fastlane rocks.Duomo
Amazing, if Fastlane is setup then this is one of the best ;)Trollop
How do you do this for different flavors ?Ima
B
9

After building an Archive of your Flutter app (using Xcode), you can run the following command from your Flutter App's ios directory (using Firebase's upload tool):

Pods/FirebaseCrashlytics/upload-symbols -gsp /path/to/GoogleService-Info.plist -p ios build/Runner.xcarchive/dSYMs

Change the above command line to point to the correct Firebase plist file. the -p flag specifies platform (which can be ios, mac, or tvos). The above command will also look for the App's archive file Runner.xcarchive.

Blunderbuss answered 25/1, 2021 at 18:0 Comment(0)
A
5

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,

  1. Ensure you have setup your build schemes correctly, else the next steps will probably not work for you. PS: I use this medium post.

  2. 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
  1. 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

Enable dSYMs for Release build

  1. Then add a Run Script with name [firebase_crashlytics] Upload dSYMs to Firebase Crashlytics (or whatever).

  2. 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
  1. 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)

Input Files section

See the Firebase docs for more info

That's all!

Annoyance answered 30/9, 2022 at 18:26 Comment(1)
Very nice, and I you could make it even simpler by just providing -gsp "${GOOGLESERVICE_INFO_FILE}" at each step and not needing APP_ID. FYI the -ai flag help states: Provide your Firebase app id directly without parsing the Google service plist. This flag will supersede the -gsp, --google-service-plist flag.Bola
H
3

Currently, a recommended approach is to add a Run Script Phase that uploads dSYMs to Crashlytics on every build.

  1. From Xcode, select Runner from the project navigation.
  2. Select the Build Phases tab, then click + > New Run Script Phase.
  3. Add the following to the Type a script... text box underneath the Shell property:
$PODS_ROOT/FirebaseCrashlytics/upload-symbols --build-phase --validate -ai <googleAppId>
$PODS_ROOT/FirebaseCrashlytics/upload-symbols --build-phase -ai <googleAppId>

Retrieve your <googleAppId> from your generated DefaultFirebaseOptions file (appId) or from the Firebase Console -> Project Settings -> Your apps.

enter image description here

Taken from here

Hermia answered 31/1, 2022 at 9:42 Comment(1)
firebase.google.com/docs/crashlytics/… Here's the updated source on how it's done. The link posted on the answer is outdatedSlant
R
0

With recent version of flutter/crashlytics, adding

-ai "[App ID]"

into

Runner -> Build Phases -> [firebase_crashlytics] Crashlytics Upload Symbols

was the only thing that was needed in my case.

Full line looks like this:

"$PODS_ROOT/FirebaseCrashlytics/upload-symbols" --flutter-project "$PROJECT_DIR/firebase_app_id_file.json" -ai "1:my_apple_app_id"

Flutter 3.16.5

firebase_crashlytics: ^3.4.9

Docs: https://firebase.google.com/docs/crashlytics/get-deobfuscated-reports?platform=flutter

Ribaudo answered 5/1 at 17:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.