fastlane: upload_symbols_to_crashlytics did not handle SPM Crashlytics Solution

New Issue Checklist

Issue Description

upload_symbols_to_crashlytics not working with Firebase Crashlytics SPM Solution.

Error Message

Failed to find Fabric's upload_symbols binary at /Applications/Fabric.app/**/upload-symbols or ./Pods/**/upload-symbols. Please specify the location of the binary explicitly by using the binary_path option

To Fix this Bug, we need to add some code on Line 105 in https://github.com/fastlane/fastlane/blob/master/fastlane/lib/fastlane/actions/upload_symbols_to_crashlytics.rb#L105

params[:binary_path] ||= (Dir["/Applications/Fabric.app/**/upload-symbols"] + Dir["./Pods/Fabric/upload-symbols"] + Dir["./scripts/upload-symbols"] + Dir["./Pods/FirebaseCrashlytics/upload-symbols"]).last

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 9
  • Comments: 55 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Yet another approach, based on #12232:

def crashlytics_binary_path
  product_module_name = "SomeModule"  # Update with your module's name
  derived_data_path = Fastlane::Actions::ClearDerivedDataAction
    .available_options[0]
    .default_value
    .gsub('~', Dir.home)
  glob_path = "#{derived_data_path}/#{product_module_name}-*/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/upload-symbols"
  Dir.glob(glob_path)[0]
end

upload_symbols_to_crashlytics(
  binary_path: crashlytics_binary_path
)

Still relevant

EDIT (due to me misreading your last lines): The simple solution could be just to specify the path to your scripts folder (and manually copying the upload script there) in your Fastfile.

upload_symbols_to_crashlytics(
   binary_path: './scripts/upload-symbols'
)

Still relevant

I ended up with the following solution in case if Firebase provided through SPM, but you still using Cocopods and hence has a workspace and different build schemes (which is frequent case)

  lane :refresh_dsyms do |options|
    buildVersion = options[:buildVersion]
    buildNumber = options[:buildNumber]
    gspPath = options[:gspPath]
    appIdentifier = options[:appIdentifier]
    scheme = options[:scheme]
    workspace = '../YOUR_WORKSPACE_NAME.xcworkspace'

    # As Firebase added to project through SPM the location of upload-symbols
    # script is not handled by upload_symbols_to_crashlytics automatically,
    # so we need to find it and provide to action
    UPLOAD_SYMBOLS_PATH=`xcodebuild -workspace #{workspace} -showBuildSettings -scheme #{scheme} | grep -m 1 "BUILD_DIR" | grep -oEi "\/.*" | sed 's:Build/Products:SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/upload-symbols:' | tr -d '\n'`

    UI.success "UPLOAD_SYMBOLS_PATH = #{UPLOAD_SYMBOLS_PATH}"

    # Download dSYM files from iTC
    download_dsyms(
        app_identifier: appIdentifier,
        version: buildVersion,
        build_number: buildNumber
    )

    # Upload them to Crashlytics
    upload_symbols_to_crashlytics(
        gsp_path: gspPath,
        binary_path: UPLOAD_SYMBOLS_PATH
    )

    # Delete the local dSYM files
    clean_build_artifacts
  end

I modified the script and used it like this:

lane :refresh_dsyms do
    download_dsyms
    UPLOAD_SYMBOLS_PATH=`xcodebuild -project ../project.xcodeproj -showBuildSettings | grep -m 1 "BUILD_DIR" | grep -oEi "\/.*" | sed 's:Build/Products:SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/upload-symbols:' | tr -d '\n'`

    upload_symbols_to_crashlytics(
      gsp_path: "../GoogleService-Info.plist",
      binary_path: UPLOAD_SYMBOLS_PATH
    )
    clean_build_artifacts
end

@StefaniOSApps I use this command: xcodebuild -showBuildSettings | grep -m 1 "BUILD_DIR" | grep -oEi "\/.*" | sed 's/Build\/Products/SourcePackages\/checkouts\/firebase-ios-sdk\/Crashlytics\/upload-symbols/' to get the path to upload-symbols and I put it in a environment variable:

UPLOAD_SYMBOLS_PATH=`xcodebuild -showBuildSettings | grep -m 1 "BUILD_DIR" | grep -oEi "\/.*" | sed 's/Build\/Products/SourcePackages\/checkouts\/firebase-ios-sdk\/Crashlytics\/upload-symbols/'`

After that I use the Ruby ENV constant in the Fastfile to get the path:

  lane :refresh_dsyms do
    download_dsyms
    upload_symbols_to_crashlytics(gsp_path: ENV['GSP_PATH'], binary_path: ENV['UPLOAD_SYMBOLS_PATH'])
    clean_build_artifacts
  end

/cc @iOSGeekster

Yet another approach, based on #12232:

def crashlytics_binary_path
  product_module_name = "SomeModule"  # Update with your module's name
  derived_data_path = Fastlane::Actions::ClearDerivedDataAction
    .available_options[0]
    .default_value
    .gsub('~', Dir.home)
  glob_path = "#{derived_data_path}/#{product_module_name}-*/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/upload-symbols"
  Dir.glob(glob_path)[0]
end

upload_symbols_to_crashlytics(
  binary_path: crashlytics_binary_path
)

Seems like a good solution, we need to locate firebase package in case of using SPM what upload_symbols_to_crashlytics can’t do for now. Looking forward to have something similar and universal under the hood of upload_symbols_to_crashlytics script

Hi I provide a better solution as workaround,

Modify crashlytics script on Build Phases from

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

to

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

# upload_symbols_to_crashlytics did not handle SPM Crashlytics Solution
# https://github.com/fastlane/fastlane/issues/17288
UPLOAD_SYMBOLS_FROM="${BUILD_DIR%Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/upload-symbols"
UPLOAD_SYMBOLS_TO_DIR="${PODS_ROOT}/FirebaseCrashlytics/"
mkdir -p "${UPLOAD_SYMBOLS_TO_DIR}" && cp "${UPLOAD_SYMBOLS_FROM}" "${UPLOAD_SYMBOLS_TO_DIR}"

EDIT (due to me misreading your last lines):

The simple solution could be just to specify the path to your scripts folder (and manually copying the upload script there) in your Fastfile.


upload_symbols_to_crashlytics(

   binary_path: './scripts/upload-symbols'

)

hmm I need a clean solution … this looks like as a workaround

Still relevant

Same issue on latest version

I found this solution that worked out great for me. Credits to Sarun!

Still relevant for apps with enabled bitcode and Xcode 13.

Are there any other reasons to use this lane except for syncing dSYMs for apps with enabled bitcode? 🤔 Apple is deprecating Bitcode in Xcode 14, so this won’t be an issue anymore?

Still relevant

Thanks for re-opening @joshdholtz. Of note Firebase is tracking the issue as well as it’s not as ideal having to find it in the build artifacts. I’d hold off fixing this in fastlane until they determine their solution. https://github.com/firebase/firebase-ios-sdk/issues/6864

I for now just decided to follow @iOSGeekster’s solution to copy it to ./scripts/upload-symbols. Also because Fastlane already looks for it there, you don’t even need to add binary_path to the upload_symbols_to_crashlytics call. Nice and clean I just need to now track them making changes to that script.

I modified the script and used it like this:

lane :refresh_dsyms do
    download_dsyms
    UPLOAD_SYMBOLS_PATH=`xcodebuild -project ../project.xcodeproj -showBuildSettings | grep -m 1 "BUILD_DIR" | grep -oEi "\/.*" | sed 's:Build/Products:SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/upload-symbols:' | tr -d '\n'`

    upload_symbols_to_crashlytics(
      gsp_path: "../GoogleService-Info.plist",
      binary_path: UPLOAD_SYMBOLS_PATH
    )
    clean_build_artifacts
end

Awsome!!!

For react native this worked for me:

upload_symbols_to_crashlytics(
    ...,
    binary_path: "./ios/Pods/FirebaseCrashlytics/upload-symbols",
    ...,
)

Changed to using Firebase SPM recently, still broken.

Same issue on latest version