Upload dSYMS to Firebase via Fastlane

Details

  • Xcode Version 11.3.1 (11C504)
  • Firebase tools 7.14.0
  • Fastlane 2.143.0

Solution

./fastlane/Pluginfile

gem 'fastlane-plugin-firebase_app_distribution'

Lane

before_all do
    # Update fastlane
    update_fastlane
    # Update fastlane plugins
    sh("fastlane update_plugins")
    # Update firebase tools
    sh("curl -sL firebase.tools | upgrade=true bash")
end

Usage 1.

Download dsyms from AppStore and upload to firebase

download_dsyms(version: '1.0', build_number: '1')
upload_symbols_to_crashlytics(gsp_path: "./App/Environment/production/GoogleService-Info-production.plist")

Usage 2.

Get dsyms from archive (after build) and upload to firebase

gym(
    configuration: 'Release',
    scheme: 'MyApp',
    include_bitcode: true
   )
upload_symbols_to_crashlytics(gsp_path: "./App/Environment/production/GoogleService-Info-production.plist")

Info

  • get_version_number
  • download_dsyms
  • sh
  • update_fastlane
  • upload_symbols_to_crashlytics

First, you need to use upload_symbols_to_crashlytics but before to use it you will need to download your dsyms from App Store Connect and to do that you should use download_dsyms with some parameters version and build_number and the Fastlane will ask you about your app_identifier so I advise you to use it to not interrupt the build until getting your answer.

desc "Upload any dsyms in the current directory to Crashlytics of firebase"
lane :upload_dsyms do |options|

  version_number = get_version_number(target: "your_app_target")
  build_number = get_build_number
  download_dsyms(
    app_identifier: "your_app_identifier",
    version: version_number,
    build_number: build_number
  )
  upload_symbols_to_crashlytics(gsp_path: "./your_app_name or your_app_target/another_directroy/GoogleService-Info.plist")
  clean_build_artifacts
end

my app was

desc "Upload any dsyms in the current directory to Crashlytics of firebase"
lane :upload_dsyms do |options|

  version_number = get_version_number(target: "Movies")
  build_number = get_build_number
  download_dsyms(
    app_identifier: "com.vngrs.Movies.demo",
    version: version_number,
    build_number: build_number
  )
  upload_symbols_to_crashlytics(gsp_path: "./Movies/Resources/GoogleService-Info.plist")
  clean_build_artifacts
end

This may not be an option for most, but I just ended up fixing this by starting over. It may not be entirely obvious if you came over from Fabric, but I figured I would just rip off the band aid. My original setup was using the Fabric(Answers)/Firebase Crashlytics which is the Fabric->Firebase migration path, although subtle, the configuration between the two are slightly different and cause issues with upload_symbols_to_crashlytics

  1. Remove support for Fabric answers, or replace with https://firebase.google.com/docs/analytics/ios/start
  2. Remove the Fabric declaration in Info.plist
  3. Modify your existing run script in BuildPhases: replace your existing runscript with "${PODS_ROOT}/Fabric/run" and add $(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH) to input files
  4. In you AppDelegate remove Fabric.with([Crashlytics.self]) and you can also kill the import Fabric as this is now covered by Firebase
  5. Unlink fabric, re-onboard Firebase crashlytics, and select new integration.
desc "Upload any dsyms in the current directory to crashlytics"
lane :upload_dsyms do |options|
  download_dsyms(version: version_number, build_number: build_number)
  upload_symbols_to_crashlytics(gsp_path: "./App/Resources/GoogleService-Info.plist")
  clean_build_artifacts
end

anyone interested in this can follow the thread here: https://github.com/fastlane/fastlane/issues/13096

TL;DR: When you call

upload_symbols_to_crashlytics(gsp_path: "./App/GoogleService-Info.plist")

It will call a binary from the installed Fabric pod called upload_symbols and will look something like this:

./Pods/Fabric/upload-symbols -a db4d085462b3cd8e3ac3b50f118e273f077497b0 -gsp ./App/GoogleService-Info.plist -p ios /private/var/folders/x1/x6nqt4997t38zr9x7zwz72kh0000gn/T/d30181115-8238-1fr38bo/D4CE43B9-9350-3FEE-9E71-9E31T39080CD.dSYM

You'll notice that it calls it using both the Fabric API key and the GoogleService-Info.plist path. I do not know why but this will cause it not to upload. You'll have to temporarily remove the fabric configuration information from your Info.plist file before running the fastlane lane. (remember to re-add the fabric configuration).