invertase / flutterfire_cli

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

request: Add support for custom named google-services-info.json and GoogleServicesInfo.plist #161

Closed dancamdev closed 1 year ago

dancamdev commented 1 year ago

Is there an existing feature request for this?

Command

No response

Description

We should have the option to specify custom file names for the google_services_info.json and GoogleServicesInfo.plist files, so that the name doesn't collide with the existing ones.

Reasoning

This is vital in an effort to have the flutterfire_cli supporting multiple app flavors. The flutterfire_cli currently asks the user if they want to replace the files, which is not what users would want when trying to add flavors.

Additional context and comments

The end goal would be for something like this

flutterfire configure `
  --out=lib/firebase_options_dev.dart `
  --platforms=ios,android `
  --ios-bundle-id=com.example.exampledev`
  --android-package-name=com.example.exampledev `
  --google-services-file-suffix=dev `

Which would generate a new firebase project and create the google-services-info-dev.json and GoogleServicesInfoDev.plist files.

itsatifsiddiqui commented 1 year ago

Refer to #132

PR has been merged but is not available on the stable version on the pub. But you can use the pre-release version of flutter_fire_cli to achieve this use case.

New command line arguments has been added. --android-out=/android/google-services.json (Here you can specify the custom file name) --ios-out=/ios/GoogleService-Info.plist (Here you can specify the custom file name)

Refer to #132 for more information.

russellwheatley commented 1 year ago

I'm going to remove the method for renaming the file in a future release. Both iOS and android require the name of the file to match their standard naming. i.e. GoogleService-Info.plist (apple) & google-services.json (android).

The correct implementation is to put the service file in separate folders. e.g. ios/dev/GoogleService-Info.plist ios/staging/GoogleService-Info.plist

Even if you implement your own way of bundling the service file, you will still need to name the file by their convention, otherwise, the native Firebase SDKs will not recognise it. So there is no point in naming it anything else.

dancamdev commented 1 year ago

@russellwheatley that's a great point - didn't know that. You'll still be allowing for different directories though right?

russellwheatley commented 1 year ago

yes, you can take a look at this table in description for possible commands.

Use the flag --ios-out=ios/whatever/directory/GoogleService-Info.plist to write it to directory of your choice for iOS.