Taimur Ajmal
Taimur Ajmal

Reputation: 2855

Firebase automate uploading dsyms - Swift package manager

We have added dependencies via SPM. Can we automate uploading dsyms with this configuration or we have to add the Firebase package using Cocoapods or Carthage.

This is my script for uploading symbols when firebase sdk is added via SPM and it doesn't work

googleServiceFileName="GoogleService-Info"

echo "Symbols Directory"
echo "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"


"${BUILD_DIR%/Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run" -gsp
 "${PROJECT_DIR}/project/GoogleServicesInfo/${googleServiceFileName}.plist" -p ios "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"

Upvotes: 3

Views: 1884

Answers (3)

Dmytro Onyshchuk
Dmytro Onyshchuk

Reputation: 321

Here is script (ci_post_xcodebuild.sh) for Xcode Cloud for automate uploading dsyms to Firebase. Swift Package Manager (SPM)

#!/bin/sh
set -e  # Exit on any error

# Required environment variables validation
if [[ -z $CI_ARCHIVE_PATH ]]; then
    echo "Error: CI_ARCHIVE_PATH is not set"
    exit 1
fi

# Paths validation
FIREBASE_SDK_PATH="${CI_DERIVED_DATA_PATH}/SourcePackages/checkouts/firebase-ios-sdk"
if [[ ! -d "$FIREBASE_SDK_PATH" ]]; then
    echo "Error: Firebase SDK path not found at $FIREBASE_SDK_PATH"
    exit 1
fi

UPLOAD_SYMBOLS_PATH="$FIREBASE_SDK_PATH/Crashlytics/upload-symbols"
if [[ ! -f "$UPLOAD_SYMBOLS_PATH" ]]; then
    echo "Error: upload-symbols script not found at $UPLOAD_SYMBOLS_PATH"
    exit 1
fi

GOOGLE_SERVICE_INFO_PLIST_PROJECTNAME="${CI_PRIMARY_REPOSITORY_PATH}/ProjectName/Resources/GoogleService-Info.plist"
if [[ ! -f "$GOOGLE_SERVICE_INFO_PLIST_PROJECTNAME" ]]; then
    echo "Error: GoogleService-Info.plist for ProjectName not found at $GOOGLE_SERVICE_INFO_PLIST_OROVERA"
    exit 1
fi

# If all validations passed, proceed with uploading
echo "Found valid archive path: $CI_ARCHIVE_PATH, trying to upload dSYMs..."
echo "Found Firebase SDK path: $FIREBASE_SDK_PATH"
echo "Found upload-symbols script at: $UPLOAD_SYMBOLS_PATH"

# Upload dSYMs for main ProjectName app
echo "Uploading dSYMs for ProjectName using plist at: $GOOGLE_SERVICE_INFO_PLIST_PROJECTNAME"
"${UPLOAD_SYMBOLS_PATH}" -gsp "${GOOGLE_SERVICE_INFO_PLIST_PROJECTNAME}" -p ios "$CI_ARCHIVE_PATH/dSYMs"

echo "dSYM upload completed."

Upvotes: 0

welsonla
welsonla

Reputation: 328

If you are using Cocoapods to install firebase frameworks, try this:

"${SRCROOT}/Pods/FirebaseCrashlytics/run"

Upvotes: 0

Erez Hod
Erez Hod

Reputation: 1883

Following this documentation page by Google, you should do the following:

  1. Go to your project's build settings and search for debug information format, and set all build types to DWARF with dSYM File.
  2. Add a new Run Script phase and add the following line:
"${BUILD_DIR%/Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run"
  1. Under "Input Files" add the following lines:
${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}
${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${PRODUCT_NAME}
${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Info.plist
$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/GoogleService-Info.plist
$(TARGET_BUILD_DIR)/$(EXECUTABLE_PATH)

It should look something like this: enter image description here

After every run it should upload the correct symbols to Crashlytics.

Upvotes: 3

Related Questions