Upload dSYMS to Firebase via Fastlane

Viewed 10970

I am struggling to upload dSYM files to Firebase via Fastlane. I have a lane that looks like the following:

desc "Fetch and upload dSYM files to Firebase Crashlytics"
lane :refresh_dsyms_firebase do |options|
  download_dsyms(version: options[:version])        
  upload_symbols_to_crashlytics(gsp_path: "./App/GoogleService-Info.plist") 
  clean_build_artifacts
end

I confirmed that that is the correct path to the plist file, but when I try to run the lane at first I see the following:

[17:22:47]: invalid byte sequence in UTF-8
[17:22:47]: invalid byte sequence in UTF-8
[17:22:47]: invalid byte sequence in UTF-8

and then one of these for every dSYM file found:

[17:22:48]: Uploading '70DBE65E-227E-3754-89F2-EEFA6B8EEC2F.dSYM'...
[17:22:48]: Shell command exited with exit status  instead of 0.

I am trying to determine exactly what I am missing from this process. Does anyone have ideas? I am fairly new to Fastlane, so definitely assume I could be missing something basic. (Although, that empty exit status is a bit weird).

fastlane 2.107.0

EDIT(June 7th: 2021): I updated the answer from my own to one that was helpful to me at the time this was written.

There are many other great answers on this page on using Fastlane as well - please check them out

6 Answers

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

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

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

This worked for me

  desc "Downlaod and Uplaod dSYMS to Firebase"
  lane :uplaod_dsyms do 
  download_dsyms # This will download all version 
  upload_symbols_to_crashlytics(
      gsp_path: "Path to your google plist",
      binary_path: "./Pods/FirebaseCrashlytics/upload-symbols") # this goes to cocoapods of FirebaseCrashlytics 
  clean_build_artifacts # Delete the local dSYM files 
 end

This works for me.

1. Create a new lane on Fastfile

# Fastfile
default_platform(:ios)

# Constants
XCODE_PROJECT = "PROJECT.xcodeproj"
XCODE_WORKSPACE = "PROJECT.xcworkspace"
PRODUCTION_GSP_PATH = "./APP_ROOT/GoogleService-Info.plist"


platform :ios do
  desc "Push a production build to TestFlight"
  lane :upload_crashlytics_prod do 
    download_dsyms(
        version: get_version_number(xcodeproj: XCODE_PROJECT), 
        build_number: get_build_number(xcodeproj: XCODE_PROJECT)
    )
    upload_symbols_to_crashlytics(gsp_path: PRODUCTION_GSP_PATH)
  end
end

2. Now call from your shell script or terminal

fastlane upload_crashlytics_prod
Related