Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 57 additions & 50 deletions content/knowledge-firebase/firebase-crashlytics-dsym-uploading.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,51 +13,58 @@ A sample project for uploading **dSYM** files to Firebase Crashlytics can be fou

### How to upload dSYM artifacts to Firebase Crashlytics using codemagic.yaml

In order to generate debug symbols, Firebase Crashlytics must be installed using the following script in your `codemagic.yaml`:
Flutter automatically generates the app’s dSYM file when building an iOS archive with:

{{< highlight yaml "style=paraiso-dark">}}
scripts:
- name: Install Firebase Crashlytics
script: |
flutter pub add firebase_crashlytics
flutter build ipa
{{< /highlight >}}

or

Alternatively, **firebase_crashlytics: ^2.5.2** could be added in the **pubspec.yaml** file under **dependencies**:
{{< highlight yaml "style=paraiso-dark">}}
flutter build ios --release
{{< /highlight >}}

Crashlytics must also be added to your app:
{{< highlight yaml "style=paraiso-dark">}}
flutter pub add firebase_crashlytics

{{< /highlight >}}

or by adding **firebase_crashlytics** dependency manually in the **pubspec.yaml** file:

{{< highlight yaml "style=paraiso-dark">}}
dependencies:
flutter:
sdk: flutter
firebase_crashlytics: ^2.5.2
firebase_crashlytics: ^latest
{{< /highlight >}}


As soon as your build finishes successfully, debug symbols are generated. However, if you want them to be displayed in the Codemagic UI on the build page, then the following path needs to be configured in `codemagic.yaml` under the artifacts section:

{{< highlight yaml "style=paraiso-dark">}}
artifacts:
- $HOME/Library/Developer/Xcode/DerivedData/**/Build/**/*.dSYM
artifacts:
- $HOME/Library/Developer/Xcode/DerivedData/**/Build/**/*.dSYM
{{< /highlight >}}

In order to upload the dSYM files to Firebase Crashlytics, add the following script to your `codemagic.yaml` configuration file:

{{< highlight yaml "style=paraiso-dark">}}
publishing:
scripts:
- name: Upload debug symbols to Firebase Crashlytics
script: |
echo "Find build artifacts"
dsymPath=$(find $CM_BUILD_DIR/build/ios/archive/Runner.xcarchive -name "*.dSYM" | head -1)
if [[ -z ${dsymPath} ]]
then
echo "No debug symbols were found, skip publishing to Firebase Crashlytics"
else
echo "Publishing debug symbols from $dsymPath to Firebase Crashlytics"
ls -d -- ios/Pods/*
$CM_BUILD_DIR/ios/Pods/FirebaseCrashlytics/upload-symbols \
-gsp ios/Runner/GoogleService-Info.plist -p ios $dsymPath
fi
scripts:
echo "Locating dSYM artifacts..."
dsymPath=$(find $CM_BUILD_DIR/build/ios/archive/Runner.xcarchive/dSYMs -name "Runner.app.dSYM" | head -1)

if [[ -z "$dsymPath" ]]; then
echo "No app dSYM file found, skipping upload."
else
echo "Uploading dSYM file: $dsymPath"
$CM_BUILD_DIR/ios/Pods/FirebaseCrashlytics/upload-symbols \
-gsp ios/Runner/GoogleService-Info.plist \
-p ios "$dsymPath"
fi

{{< /highlight >}}

The above-mentioned **dsymPath** is Flutter specific and it could change depending on what platform the app is built on. For example, in React Native or Native iOS applications you might use the dsymPath as:
Expand All @@ -83,41 +90,41 @@ If necessary, you can use remote access to the build machine to find the correct
For Native iOS apps, in the case of using SwiftPackageManager (SPM) instead of CocoaPods, the following script needs to be added in a post-publishing script:

{{< highlight yaml "style=paraiso-dark">}}
publishing:
scripts:
- name: Upload debug symbols to Firebase Crashlytics
script: |
echo "Find build artifacts"
dsymPath=$(find build/ios/xcarchive/* | head -1)
echo "dsyms expected in:"
ls -d -- $dsymPath/dSYMs/*
dsymFile=$(find $dsymPath/dSYMs -name "*.dSYM" | head -1)
if [[ -z ${dsymFile} ]]
then
echo "No debug symbols were found, skip publishing to Firebase Crashlytics"
else
echo "Publishing debug symbols in $dsymFile to Firebase Crashlytics"
echo $dsymFile
ls -d -- $CM_BUILD_DIR/*
$HOME/Library/Developer/Xcode/DerivedData/**/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/upload-symbols \
-gsp $CM_BUILD_DIR/<PATH_TO_YOUR_GoogleService-Info.plist> -p ios $dsymFile
fi
publishing:
scripts:
- name: Upload debug symbols to Firebase Crashlytics
script: |
echo "Find build artifacts"
dsymPath=$(find build/ios/xcarchive/* | head -1)
echo "dsyms expected in:"
ls -d -- $dsymPath/dSYMs/*
dsymFile=$(find $dsymPath/dSYMs -name "*.dSYM" | head -1)
if [[ -z ${dsymFile} ]]
then
echo "No debug symbols were found, skip publishing to Firebase Crashlytics"
else
echo "Publishing debug symbols in $dsymFile to Firebase Crashlytics"
echo $dsymFile
ls -d -- $CM_BUILD_DIR/*
$HOME/Library/Developer/Xcode/DerivedData/**/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/upload-symbols \
-gsp $CM_BUILD_DIR/<PATH_TO_YOUR_GoogleService-Info.plist> -p ios $dsymFile
fi
{{< /highlight >}}

### How to upload dSYM artifacts to Firebase Crashlytics using Workflow Editor

In order to upload the dSYM files to Firebase Crashlytics, add the following script to your **post-publish** script in the Flutter workflow editor:

{{< highlight yaml "style=paraiso-dark">}}
echo "Find build artifacts"
dsymPath=$(find $CM_BUILD_DIR/build/ios/archive/Runner.xcarchive -name "*.dSYM" | head -1)
if [[ -z ${dsymPath} ]]
then
echo "No debug symbols were found, skip publishing to Firebase Crashlytics"
echo "Locating dSYM artifacts..."
dsymPath=$(find $CM_BUILD_DIR/build/ios/archive/Runner.xcarchive/dSYMs -name "Runner.app.dSYM" | head -1)

if [[ -z "$dsymPath" ]]; then
echo "No app dSYM file found, skipping upload."
else
echo "Publishing debug symbols from $dsymPath to Firebase Crashlytics"
ls -d -- ios/Pods/*
echo "Uploading dSYM file: $dsymPath"
$CM_BUILD_DIR/ios/Pods/FirebaseCrashlytics/upload-symbols \
-gsp ios/Runner/GoogleService-Info.plist -p ios $dsymPath
-gsp ios/Runner/GoogleService-Info.plist \
-p ios "$dsymPath"
fi
{{< /highlight >}}