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]: `flutterfire configure` uses the `RunnerTests` target instead the `Runnter target` for macOS #182

Closed nilsreichardt closed 8 months ago

nilsreichardt commented 1 year ago

Is there an existing issue for this?

CLI Version

0.2.7

Firebase Tools version

12.3.1

Flutter Doctor Output

Flutter 3.10.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 682aa387cf (7 days ago) • 2023-06-05 18:04:56 -0500
Engine • revision 2a3401c9bb
Tools • Dart 3.0.3 • DevTools 2.23.1

Description

My macOS app has the bundle identifier com.example.exampleFlutterfireBugMacos. However, when I run flutterfire configure, the FlutterFire CLI uses the com.example.exampleFlutterfireBugMacos.RunnerTests bundle identifier of the RunnerTests target. I think the RunnerTests target will be added for every macOS app since the last stable Flutter version.

Steps to reproduce

  1. flutter create your_name
  2. flutterfire configure

Expected behavior

The CLI should use the com.example.exampleFlutterfireBugMacos bundle identifier

Screenshots

Nils-MBP-13-M1-4:example_flutterfire_bug_macos nils$ flutterfire configure
i Found 16 Firebase projects.                                                                                           
✔ Select a Firebase project to configure your Flutter application with · nilsreichardt-play (nilsreichardt-play)        
✔ Which platforms should your configuration support (use arrow keys & space to select)? · android, ios, macos, web      
i Firebase android app com.example.example_flutterfire_bug_macos is not registered on Firebase project nilsreichardt-play.
i Registered a new Firebase android app on Firebase project nilsreichardt-play.                                         
i Firebase ios app com.example.exampleFlutterfireBugMacos is not registered on Firebase project nilsreichardt-play.     
i Registered a new Firebase ios app on Firebase project nilsreichardt-play.                                             
i Firebase macos app com.example.exampleFlutterfireBugMacos.RunnerTests is not registered on Firebase project nilsreichardt-play.
i Registered a new Firebase macos app on Firebase project nilsreichardt-play.                                           
i Firebase web app example_flutterfire_bug_macos (web) registered.                                                      
? The files android/build.gradle & android/app/build.gradle will be updated to apply Firebase configuration and gradle b? The files android/build.gradle & android/app/build.gradle will be updated to apply Firebase configuration and gradle b✔ The files android/build.gradle & android/app/build.gradle will be updated to apply Firebase configuration and gradle build plugins. Do you want to continue? · yes 

Firebase configuration file lib/firebase_options.dart generated successfully with the following Firebase apps:

Platform  Firebase App Id
web       1:56764935785:web:6042240c8935a48fe6bcf8
android   1:56764935785:android:051c68aee3623e4ce6bcf8
ios       1:56764935785:ios:fabc1759e9eea156e6bcf8
macos     1:56764935785:ios:7b3408af32c032c6e6bcf8

Learn more about using this file and next steps from the documentation:
 > https://firebase.google.com/docs/flutter/setup

Additional context and comments

No response

russellwheatley commented 1 year ago

Does this occur on the latest dev release? It's not an issue on the latest. Hopefully get a release out soon enough.

vincekruger commented 10 months ago

I upgraded the CLI last night and still got this issue. The CLI is looking at the in PRODUCT_BUNDLE_IDENTIFIER macos/Runner/Configs/AppInfo.xcconfig which somehow always gets set to the test build identifier.

russellwheatley commented 9 months ago

@nilsreichardt Have you tried with the latest dev release? It is a lot more stable -

dart pub global activate flutterfire_cli 0.3.0-dev.18 --overwrite
JasCodes commented 9 months ago

@russellwheatley Yes, but still the issue persists

giapmn-1380 commented 8 months ago

I have same issue. I remove target RunnerTests and flutterfire configure again :(

russellwheatley commented 8 months ago

Bug has been confirmed and I've made a PR with a fix.

almogtovim commented 7 months ago

so how can I fix it? I deleted the issued (RunnerTests) app ios app from firebase console. Now I'm getting the following macod registration error when running fluterfire configure:


FirebaseCommandException: An error occured on the Firebase CLI when attempting to run a command.
COMMAND: firebase apps:create ios my-app (macos) --bundle-id=com.myapp.RunnerTests --json --project=my-project
ERROR: Failed to create iOS app for project my-project. See firebase-debug.log for more info
```. 
kimfucious commented 7 months ago

so how can I fix it? I deleted the issued (RunnerTests) app ios app from firebase console. Now I'm getting the following macod registration error when running fluterfire configure:

FirebaseCommandException: An error occured on the Firebase CLI when attempting to run a command.
COMMAND: firebase apps:create ios my-app (macos) --bundle-id=com.myapp.RunnerTests --json --project=my-project
ERROR: Failed to create iOS app for project my-project. See firebase-debug.log for more info
```. 

Hi @almogtovim,

I had this issue, and needed to permanently delete all apps in the Firebase Console and remove any current configuration files in my flutter project to make this go away.

I also believe this bug still exists, as I too was seeing flutter fire use the wrong bundle id. What worked for me was using the below to specify a bundle id for the macos app:

flutterfire configure --macos-bundle-id=com.<your_domain>.<your_appname>.macos --project=your_project_id

macos in the above is a unique identifier (it can be anything) so that it does not conflict with your ios bundle id.

stuffai-bk commented 2 months ago

This is still an issue for me. Looking into it a bit, doing a regex.firstMatch seems rather unstable when the xcode project file has multiple build targets for debug/release/profile in both the runner and runnertest.

https://github.com/invertase/flutterfire_cli/blob/main/packages/flutterfire_cli/lib/src/flutter_app.dart#L90

EDIT: For users, the hacky fix is to go into the project's ios/Runner.xcodeproj/project.pbxproj file and manually move the block with the desired project bundle identifier to the top of the file.