skip to Main Content

Using XCode10.5.1, iOS 14.6, Swift5.4.2,

Using the Swift Package Manger (SPM) for getting Firebase dependency in to my project – I try to get going Google Crashlytics on my iOS device.

I saw in several posts (ex. this one) that in order for Crashlytics to work via the SPM, you need to add a Build run script in Xcode as follows:

${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run

Now since I do have two different configurations defines (DEV and PROD), I somehow need to make this run script know about this.

My script looks as follows:

if ["${CONFIGURATION}" == "Release"] || ["${CONFIGURATION}" == "Debug"]; then
    ${BUILD_DIR%Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run
elif ["${CONFIGURATION}" == "ReleaseDev"] || ["${CONFIGURATION}" == "DebugDev"]; then
  ${BUILD_DIR%Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run -gsp ${PROJECT_DIR}/iOS/SupportFiles/GoogleService-InfoDev.plist
fi

But Crashlytics still does not work !

enter image description here

Question NR1: How does the run script look like for Crashlytics to work with SPM ?

Question NR2: In particular, how can I improve my run script for making a clear distinction between DEV and PROD environment. (so far I need to do the workaround with CONFIGURATION).

2

Answers


  1. Chosen as BEST ANSWER

    Here is a working example of Crashlytics in Xcode when used via Swift Package Manager (i.e. not via Cocoapod):

    I found the solution - the run Script had a wrong syntax.

    Here is the correct one:

    echo "Configuration = $CONFIGURATION";
    if [ $CONFIGURATION == 'Debug' ] || [ $CONFIGURATION == 'Release' ]; then
      echo "PROD";
      ${BUILD_DIR%Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run -gsp ${PROJECT_DIR}/iOS/SupportFiles/GoogleService-Info.plist;
    elif [ $CONFIGURATION == 'DebugDev' ] || [ $CONFIGURATION == 'ReleaseDev' ]; then
      echo "DEV";
      ${BUILD_DIR%Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run -gsp ${PROJECT_DIR}/iOS/SupportFiles/GoogleService-InfoDev.plist;
    fi
    

    Of course, Debug, Release, DebugDev and ReleaseDev depends on your own naming of your configurations in Xcode.

    This way, the two configurations DEV and PROD both work with Google Crashlytics. The script makes sure the necessary dSYM files are sent to Google once a crash occurs.

    To verify that the script is executed, you can follow the echo print under the report Navigator in Xcode (i.e. see screenshot)

    enter image description here


  2. I am unable to edit the above post. [showing "Suggested edit queue is full"]
    So commenting here:
    There is an issue in the script here https://stackoverflow.com/a/68460653/3913535

    $CONFIGURATION should be in quotes inside the if condition.

    if [ "$CONFIGURATION" == 'Debug' ] || [ "$CONFIGURATION" == 'Release' ]; then
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search