flutterfire_cli icon indicating copy to clipboard operation
flutterfire_cli copied to clipboard

[bug]: macOS dSYM upload fails when configured with SPM and build flavors

Open amrgetment opened this issue 9 months ago • 8 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues.

It is similar to this issue, but for macO,S not iOS https://github.com/invertase/flutterfire_cli/issues/371 I need a similar fix but for macOS https://github.com/invertase/flutterfire_cli/pull/367

CLI Version

1.2.0

Firebase Tools version

13.29.1

Flutter Doctor Output

Toggle me!
[✓] Flutter (Channel stable, 3.29.3, on macOS 15.3.1 24D70 darwin-x64, locale en-EG) [784ms]
    • Flutter version 3.29.3 on channel stable at /Users/amr/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ea121f8859 (12 days ago), 2025-04-11 19:10:07 +0000
    • Engine revision cf56914b32
    • Dart version 3.7.2
    • DevTools version 2.42.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1) [10.6s]
    • Android SDK at /Users/amr/Desktop/private/programming/sdks/Android/sdk
    • Platform android-35, build-tools 35.0.1
    • ANDROID_HOME = /Users/amr/Desktop/private/programming/sdks/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13355223-b631.42)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.3) [2.1s]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16E140
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [39ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.3) [38ms]
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13355223-b631.42)

[✓] VS Code (version 1.99.3) [32ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.108.0

[✓] VS Code (version 1.100.0-insider) [32ms]
    • VS Code at /Applications/Visual Studio Code - Insiders.app/Contents
    • Flutter extension version 3.109.20250401

[✓] Connected device (2 available) [7.5s]
    • macOS (desktop) • macos  • darwin-x64     • macOS 15.3.1 24D70 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 135.0.7049.96

[✓] Network resources [1,010ms]
    • All expected network resources are available.

• No issues found!

Description

The Flutterfire CLI script to upload the dsym for macOS is not working with SPM

Unhandled exception:
ProcessException: No such file or directory
  Command: /Users/amr/Desktop/private/programming/amr/sources/mobile-app/build/macos/Build/Products/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run --validate --flutter-project /Users/amr/Desktop/private/programming/ment/sources/mobile-app/.dart_tool/flutterfire/platforms/macos/targets/Runner/ment-sit/app_id_file.json
#0      _ProcessImpl._start (dart:io-patch/process_patch.dart:422:33)
#1      Process.start (dart:io-patch/process_patch.dart:42:20)
#2      _runNonInteractiveProcess (dart:io-patch/process_patch.dart:626:18)
#3      Process.run (dart:io-patch/process_patch.dart:56:12)
#4      UploadCrashlyticsSymbols.run (package:flutterfire_cli/src/commands/upload_symbols.dart:368:44)
<asynchronous suspension>
#5      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#6      main (file:///Users/amr/.pub-cache/hosted/pub.dev/flutterfire_cli-1.2.0/bin/flutterfire.dart:63:5)
flutterfire.dart:63
<asynchronous suspension>
Command PhaseScriptExecution failed with a nonzero exit code
warning: Run script build phase 'FlutterFire: "flutterfire upload-crashlytics-symbols"' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Runner' from project 'Runner')
warning: Run script build phase 'Copy GoogleServices-Info.plist to the correct location' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Runner' from project 'Runner')
** BUILD FAILED **

Error: Build process failed

Steps to reproduce

  1. Run flutterfire cli on a Flutter project with macOS
  2. Enable SPM for that project
  3. Add Crashlytics
  4. Build the project

Expected behavior

No crash

Screenshots

No response

Additional context and comments

No response

amrgetment avatar Apr 23 '25 12:04 amrgetment

Same issue

solshark avatar May 06 '25 14:05 solshark

Modified version - workaround solution

#!/bin/bash
PATH="${PATH}:$FLUTTER_ROOT/bin:${PUB_CACHE}/bin:$HOME/.pub-cache/bin"

# Default fallback
PATH_TO_CRASHLYTICS_UPLOAD_SCRIPT=""

# CocoaPods (iOS)
if [ -n "$PODS_ROOT" ] && [ -d "$PODS_ROOT/FirebaseCrashlytics" ]; then
  PATH_TO_CRASHLYTICS_UPLOAD_SCRIPT="$PODS_ROOT/FirebaseCrashlytics/run"

# Xcode SPM (DerivedData)
elif [ -n "$BUILD_ROOT" ]; then
  DERIVED_DATA_PATH=$(echo "$BUILD_ROOT" | sed -E 's|(.*DerivedData/[^/]+).*|\1|')
  DERIVED_SPM_PATH="${DERIVED_DATA_PATH}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run"
  if [ -f "$DERIVED_SPM_PATH" ]; then
    PATH_TO_CRASHLYTICS_UPLOAD_SCRIPT="$DERIVED_SPM_PATH"
  fi
fi

# Flutter SPM (build/macos)
if [ -z "$PATH_TO_CRASHLYTICS_UPLOAD_SCRIPT" ]; then
  PROJECT_ROOT="$(cd "$SRCROOT/.." && pwd)"
  FLUTTER_SPM_PATH="${PROJECT_ROOT}/build/macos/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run"
  if [ -f "$FLUTTER_SPM_PATH" ]; then
    PATH_TO_CRASHLYTICS_UPLOAD_SCRIPT="$FLUTTER_SPM_PATH"
  fi
fi

# Throw error if path not found
if [ ! -f "$PATH_TO_CRASHLYTICS_UPLOAD_SCRIPT" ]; then
  echo "❌ Firebase Crashlytics run script not found!"
  exit 1
fi

# Upload symbol
flutterfire upload-crashlytics-symbols \
  --upload-symbols-script-path="$PATH_TO_CRASHLYTICS_UPLOAD_SCRIPT" \
  --platform=macos \
  --apple-project-path="${SRCROOT}" \
  --env-platform-name="${PLATFORM_NAME}" \
  --env-configuration="${CONFIGURATION}" \
  --env-project-dir="${PROJECT_DIR}" \
  --env-built-products-dir="${BUILT_PRODUCTS_DIR}" \
  --env-dwarf-dsym-folder-path="${DWARF_DSYM_FOLDER_PATH}" \
  --env-dwarf-dsym-file-name="${DWARF_DSYM_FILE_NAME}" \
  --env-infoplist-path="${INFOPLIST_PATH}" \
  --default-config=default

volkangurol avatar May 21 '25 23:05 volkangurol

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar Jun 18 '25 23:06 github-actions[bot]

@volkangurol - not sure what setup I need to reproduce this. If you want, you could create a PR and update the logic for path to upload symbols script here so it fixes this issue on macOS as well: https://github.com/invertase/flutterfire_cli/blob/main/packages/flutterfire_cli/lib/src/firebase/firebase_apple_writes.dart#L404-L406

russellwheatley avatar Jun 23 '25 10:06 russellwheatley

@volkangurol Your solution works fine for me

amrgetment avatar Jun 23 '25 11:06 amrgetment

Looks like the cause of the issue is the order of the build phase scripts that FlutterFire adds.

I faced the above issue today. Was setting up FlutterFire with flavors in 2 different projects and faced the exact same issue. After trying multiple solutions, brainstorming, debugging, and checking FlutterFire's source code, I had the thought that what if the "Upload Crashlytic Symbols" didn't yet have what it takes to run and was failing.

I then came back and checked and realised that the "Bundle Service File" build phase script was after "Upload Crashlytics Symbol". On re-ordering to make "Bundle Service File" first, the problem got solved and the build was successful for both Flutter apps/projects.


By default, after running flutterfire configure multiple times with each flavor, the Build Phase Scripts will be in the following order:

FlutterFire 'Upload Crashlytics Symbols' before 'Bundle Service File'

But when you re-order them to make "Bundle Service File" first as follows, then the above issue gets solved:

Image

My hypothesis is as follows:

When you select Targets during flutterfire configure for iOS, it sets up the GoogleService-Info.plist file in the root iOS directory and adds just the "Upload Crashlytics Symbols" build phase script (I stand to be corrected).

However, when you setup FlutterFire with BuildConfigurations which is what you do with flavors, FlutterFire goes on to add another "Bundle Service File" build phase script alongside "Upload Crashlytics Symbols". This script copies the flavored GoogleService-Info.plist file from the respective flavor directory you put it into Runner.app at Xcode's build time, and this is what we want.

I am supposing that users that don't use flavors might not run into the above issue because GoogleService-Info.plist is already present in Runner.app from Targets setup. But when you do flavors, you face the above error because the "Bundle Service File" script that does the service file copying executes but after "Upload Crashlytics Symbols" (by default from FlutterFire). So probably, when FlutterFire wants to execute the "Upload Crashlytics Symbols", it fails as there is not yet a GoogleService-Info.plist file in the right place.

So if you reorder the Build Phase Scripts in Xcode then the problem will be solved.

Kindly test the re-ordering and check whether the problem gets solved. If yeah, then it is to update the FlutterFire package to put the Build Phase Scripts in the above order.


I came to this issue only after I solved by re-ordering. Like I felt maybe I'm not the only person facing the problem and searched for it and found this issue.

So here is me adding the above should in case it fixes it, then a package update with the corrected Build Phase Scripts order will prevent others from facing it again.

obumnwabude avatar Aug 04 '25 20:08 obumnwabude

@obumnwabude Thanks! Your solution works fine! It took 10 hours to get here...

takekapp1990 avatar Aug 28 '25 08:08 takekapp1990

@russellwheatley the solution of @obumnwabude of switching the two scripts works for me too. (notifying you because this is tagged as awaiting customer response)

Everytime configure is run, you have to swap the scripts for the build to pass.

cedvdb avatar Dec 10 '25 12:12 cedvdb