invertase / flutterfire_cli

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

[bug]: GoogleService-info.plist won't be updated when configure with another firebase project #109

Closed komi1230 closed 1 year ago

komi1230 commented 2 years ago

Is there an existing issue for this?

CLI Version

0.2.6

Firebase Tools version

11.9.0

Flutter Doctor Output

[✓] Flutter (Channel stable, 3.3.2, on macOS 12.6 21G115 darwin-x64, locale en-JP) • Flutter version 3.3.2 on channel stable at /usr/local/Caskroom/flutter/2.10.0/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision e3c29ec00c (8 days ago), 2022-09-14 08:46:55 -0500 • Engine revision a4ff2c53d8 • Dart version 2.18.1 • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at /Users/komi/Library/Android/sdk • Platform android-33, build-tools 33.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 14A309 • CocoaPods version 1.11.3

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

[✓] Android Studio (version 2021.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 11.0.12+0-b1504.28-7817840)

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

[✓] Connected device (3 available) • Yusuke Kominami’s iPhone (mobile) • 00008101-000A405C0204001E • ios • iOS 16.0 20A362 • macOS (desktop) • macos • darwin-x64 • macOS 12.6 21G115 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 105.0.5195.125 ! Error: [MY NAME]のApple Watch needs to connect to determine its availability. Check the connection between the device and its companion iPhone, and the connection between the iPhone and Xcode. Both devices may also need to be restarted and unlocked. (code 1)

[✓] HTTP Host Availability • All required HTTP hosts are available

Description

When I do below command, each JSON and plist file have successfully been created.

ENVIRONMENT=dev
flutterfire configure \
    --ios-bundle-id=com.example.example.$ENVIRONMENT \
    --android-package-name=com.example.example.$ENVIRONMENT \
    --project=example-project-$ENVIRONMENT \
    --platforms="android,ios" \
    --yes

And then configure as staging environment with another firebase project,

ENVIRONMENT=stg
flutterfire configure \
    --ios-bundle-id=com.example.example.$ENVIRONMENT \
    --android-package-name=com.example.example.$ENVIRONMENT \
    --project=example-project-$ENVIRONMENT \
    --platforms="android,ios" \
    --yes

All files except GoogleService-Info.plist are updated like this.

        modified:   android/app/google-services.json
        modified:   ios/firebase_app_id_file.json
        modified:   lib/firebase_options.dart

And in GoogleService-Info.plist development config still remains.

When I delete GoogleService-Info.plist and configure again as staging environment, then GoogleService-Info.plist is successfully created with correct configure.

Steps to reproduce

  1. flutterfire configure
  2. Again configure with another firebase project

Expected behavior

GoogleService-Info.plist should correctly be updated.

Screenshots

No response

Additional context and comments

No response

awais-amjed commented 1 year ago

✅ Encountered the same bug yesterday

OutdatedGuy commented 1 year ago

Same here. Only GoogleService-Info.plist doesn't gets updated.

Remas-Safi commented 1 year ago

For me, as a hack way, I was changing to use a new project, so I deleted the app and run the command again

josephmangmang commented 1 year ago

same here. You need to manually delete the GoogleService-Info.plist and re-run flutterfire configure

russellwheatley commented 1 year ago

I'll be updating this for the next dev release. It should update the service file.

K-Maron commented 1 year ago

A bit confused here... A while ago when I first ran flutterfire configure, it didn't even create GoogleService-Info.plist. I'm certain about this because of my git change history. It's been working all well. Now I'm running flutterfire configure again while reviewing my project setup, it is creating GoogleService-Info.plist. Has it been changed?

K-Maron commented 1 year ago

Quick googling made me think that FirebaseOptions and GoogleService-Info.plist have overlapping purposes if we are just doing standard or simple Flutter<>Firebase integration. Thus, in the simplest case, if we are using GoogleService-Info.plist, then it's possible that we don't need to pass FirebaseOptions into Firebase.initializeApp function?

russellwheatley commented 1 year ago

It's been adding the apple service file since this PR was released last year: https://github.com/invertase/flutterfire_cli/pull/70. It is entirely possible you don't need to use the FirebaseOptions if you're not building a web app. The web platform still needs it for initialisation.

K-Maron commented 1 year ago

@russellwheatley Thanks for the clarification! 🙏