invertase / flutterfire_cli

A CLI to help with using FlutterFire in your Flutter applications.
Apache License 2.0
164 stars 47 forks source link

[bug]: firebase.json not found #284

Closed cuongHuuk closed 2 months ago

cuongHuuk commented 2 months ago

Is there an existing issue for this?

CLI Version

1.0.0

Firebase Tools version

13.7.1

Flutter Doctor Output

[✓] Flutter (Channel stable, 3.19.3, on macOS 14.4 23E214 darwin-arm64, locale en-VN) • Flutter version 3.19.3 on channel stable at /Applications/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision ba39319843 (6 weeks ago), 2024-03-07 15:22:21 -0600 • Engine revision 2e4ba9c6fb • Dart version 3.3.1 • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/nguyencuong/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.9+0-17.0.9b1087.7-11185874) • All Android licenses accepted.

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

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

[✓] Android Studio (version 2023.2) • 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.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.87.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension can be installed from: 🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (5 available)
• SM N770F (mobile) • RF8N21H8TGX • android-arm64 • Android 13 (API 33) • sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 14 (API 34) (emulator) • Cuong’s iPhone (2) (mobile) • 886a1334c1c12e89a204e248adf297683eb6a842 • ios • iOS 16.7.7 20H330 • macOS (desktop) • macos • darwin-arm64 • macOS 14.4 23E214 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 123.0.6312.124

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

Description

My app works well on android but it throws an error on ios:

PathNotFoundException: Cannot open file, path = '/Volumes/Data/firebase.json' (OS Error: No such file or directory, errno = 2)
    #0      _checkForErrorResponse (dart:io/common.dart:55:9)
    #1      _File.open.<anonymous closure> (dart:io/file_impl.dart:381:7)
    <asynchronous suspension>
    #2      _File.readAsBytes.<anonymous closure> (dart:io/file_impl.dart:562:24)
    <asynchronous suspension>
    #3      _File.readAsString (dart:io/file_impl.dart:621:18)
    <asynchronous suspension>
    #4      appleConfigFromFirebaseJson (package:flutterfire_cli/src/common/utils.dart:286:7)
    <asynchronous suspension>
    #5      UploadCrashlyticsSymbols._getConfigurationFromFirebaseJsonFile (package:flutterfire_cli/src/commands/upload_symbols.dart:278:9)
    <asynchronous suspension>
    #6      UploadCrashlyticsSymbols.run (package:flutterfire_cli/src/commands/upload_symbols.dart:331:34)
    <asynchronous suspension>
    #7      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
    <asynchronous suspension>
    #8      main (file:///Users/nguyencuong/.pub-cache/hosted/pub.dev/flutterfire_cli-1.0.0/bin/flutterfire.dart:63:5)
    <asynchronous suspension>

Steps to reproduce

flutter run

Expected behavior

ios can run well as android

Screenshots

Screenshot 2024-04-16 at 15 45 30

Additional context and comments

No response

russellwheatley commented 2 months ago

@cuongHuuk - do you have a firebase.json file with FlutterFire configuration contained within it? It should look like this in the firebase.json file:

{
  "flutter": {
    "platforms": {
       // FLUTTERFIRE CONFIGURATION
    }
  }
}
cuongHuuk commented 2 months ago
platforms

@russellwheatley yes I have, I can run android app without error. my file look like

Screenshot 2024-04-18 at 15 49 13
russellwheatley commented 2 months ago

The problem is the path to your firebase.json. For some reason, it is /Volumes/Data/firebase.json which is incorrect.

Check this script in you run build phases on Xcode:

Screenshot 2024-04-18 at 10 38 10

It uses the SRCROOT Xcode environment variable as your project path. For some reason, your project path is /Volumes/Data.

To check what SRCROOT is for your project do the following from the root of your flutter project in your terminal:

cd ios/
xcodebuild -showBuildSettings

This will print out all Xcode environment variables. Check what SRCROOT looks like. For example, here is what mine looks like for project "sample":

Screenshot 2024-04-18 at 10 43 40

It seems to me you're doing something unusual with your Flutter project that is outside the scope of FlutterFire CLI

cuongHuuk commented 2 months ago

SRCROOT

Screenshot 2024-04-18 at 17 04 35

I think my SRCROOT is correct @russellwheatley

russellwheatley commented 2 months ago

ah, it is because you have spaces in your file path. This PR ought to solve your problem I think: https://github.com/invertase/flutterfire_cli/pull/228