invertase/flutterfire_cli

[bug]: Command PhaseScriptExecution failed with a nonzero exit code when running from Xcode

Opened this issue · 8 comments

Is there an existing issue for this?

  • I have searched the existing issues.

CLI Version

1.0.1-dev.0

Firebase Tools version

13.8.1

Flutter Doctor Output

[✓] Flutter (Channel stable, 3.19.6, on macOS 14.5 23F79 darwin-arm64, locale en-EG)
• Flutter version 3.19.6 on channel stable at /Users/bx777/.puro/envs/stable/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 54e66469a9 (5 weeks ago), 2024-04-17 13:08:03 -0700
• Engine revision c4cd48e186
• Dart version 3.3.4
• DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/bx777/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15F31d
• CocoaPods version 1.15.2

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

[✓] Android Studio (version 2022.3)
• 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 17.0.6+0-17.0.6b829.9-10027231)

[✓] VS Code (version 1.89.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.88.0

[✓] Connected device (4 available)
• Ahmed’s iPhone (mobile) • 00008020-00155D412243002E • ios • iOS 17.4.1 21E236
• iPhone 15 Pro Max (mobile) • 1B9F51D0-2C93-4450-B83A-EEC3AF400616 • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-5 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 14.5 23F79 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.209

[✓] Network resources
• All expected network resources are available.

• No issues found!

Description

When running a flutter project with flavor from VSCode or command line it works fine.

But, when running from Xcode I get an error Command PhaseScriptExecution failed with a nonzero exit code,

Using the Xcode report navigator, it shows the cause of the error is:

/Users/bx777/Library/Developer/Xcode/DerivedData/Runner-efucnxnpxngwpuawulskwwbebelt/Build/Intermediates.noindex/Runner.build/Debug-dev-iphonesimulator/Runner.build/Script-53713B544D4D72BE6CC51AC1.sh: line 5: flutterfire: command not found

Steps to reproduce

  1. Run a project with flavor using the following command:
flutter build ios --debug --flavor=dev --target=lib/main_dev.dart --dart-define-from-file=configs/dev.json
  1. It works find and run as expected
  2. Run again after the previous build success but using Xcode build this time
  3. The build fails and gives an error

Expected behavior

I expect it to run normally using Xcode build after a normal flutter build ios command "which generates and pass dart environment variables into Xcode build".

Screenshots

Screenshot 2024-05-20 at 8 38 40 PM

Additional context and comments

No response

@AhmedLSayed9

I've just ran this on Xcode and it was successful:
Screenshot 2024-05-22 at 11 41 54

The exception is saying that it cannot find flutterfire. This seems like a problem with where flutterfire is located. Before we call flutterfire, we add this to the Xcode PATH variable:

PATH="${PATH}:$FLUTTER_ROOT/bin:$HOME/.pub-cache/bin"

flutterfire executable on my machine is located here: $HOME/.pub-cache/bin. Where is it located on your machine?

flutterfire

I'm using puro for version management so mine is located at $HOME/.puro/shared/pub_cache/bin/flutterfire

That will be why it doesn't work then. Is there any way you can move it to the standard path?

That will be why it doesn't work then. Is there any way you can move it to the standard path?

I don't think that is possible when using puro.

I've found an open issue regarding this at pingbird/puro#70.
The puro's author suggests flutterfire to follow the semantics of the pub tool and use PUB_CACHE

If you could explain what that means it would be helpful. As far as I can tell, we're using the default path.

If you could explain what that means it would be helpful. As far as I can tell, we're using the default path.

I think he's referring to update the path in the script to the following:

PATH="${PATH}:$FLUTTER_ROOT/bin:$PUB_CACHE/bin"

PUB_CACHE seems to accurately retrieve the path where the "pub_cache" directory and "flutterfire" are located:

Screenshot 2024-05-23 at 7 35 09 PM

That's fair enough, I'm happy to make that change👍

edit: I will have to check now that I think about it, I'm not sure that will be available in the Xcode build environment variables.