flutterfire_cli icon indicating copy to clipboard operation
flutterfire_cli copied to clipboard

feat: Try to Support flavors (android & ios)

Open salahamassi opened this issue 2 years ago โ€ข 3 comments

Description

Firebase CLI will try to get all flavors for the android project and variant build configrations for the ios project and show a prompt to the ser

? Do you want to create a firebase project for each flavor? (y/n)

if the user selects "y" for each flavor firebase CLI will create a firebase project with selected platforms

  • create firebase_options.dart for each flavor For example: (lib/firebase_options_development.dart, lib/firebase_options_production.dart, lib/firebase_options_staging.dart)

  • create firebase_app_id_file.json for each flavor For example: (ios/firebase_app_id_file_development.json, ios/firebase_app_id_file_production.json, ios/firebase_app_id_file_staging.json)

  • create google-services.json for each flavor For example: (android/app/src/development/google-services.json, android/app/src/production/google-services.json, android/app/src/staging/google-services.json)

  • create GoogleService-Info.plist for each flavor For example: (ios/Runner/development/GoogleService-Info.plist, ios/Runner/production/GoogleService-Info.plist, ios/Runner/staging/GoogleService-Info.plist)

For ios Project add shell script to copy the correct GoogleService-Info.plist to the BUILT_PRODUCTS_DIR based on the selected ios schema:

GOOGLE_SERVICE_INFO_PLIST_FROM="${PROJECT_DIR}/Runner/${FLAVOR}/GoogleService-Info.plist"
BUILD_APP_DIR="${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}"
GOOGLE_SERVICE_INFO_PLIST_TO="${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app"
cp "${GOOGLE_SERVICE_INFO_PLIST_FROM}" "${GOOGLE_SERVICE_INFO_PLIST_TO}"

Please try it ๐Ÿ™๐Ÿš€

Type of Change

  • [x] โœจ feat -- New feature (non-breaking change which adds functionality)
  • [ ] ๐Ÿ› ๏ธ fix -- Bug fix (non-breaking change which fixes an issue)
  • [ ] โŒ ! -- Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] ๐Ÿงน refactor -- Code refactor
  • [ ] โœ… ci -- Build configuration change
  • [ ] ๐Ÿ“ docs -- Documentation
  • [ ] ๐Ÿ—‘๏ธ chore -- Chore

salahamassi avatar Jul 16 '22 12:07 salahamassi

I opened this PR based on this issue https://github.com/invertase/flutterfire_cli/issues/14

salahamassi avatar Jul 16 '22 13:07 salahamassi

I've try the PR using the VGV CLI:

very_good create project --desc "Project" --org "com.lyokone.project" 

It produces the following result:

FileSystemException: Cannot open file, path = 'project/android/app/src/production/google-services.json' (OS Error: No such file or directory, errno = 2)

I feel like matching the name of the flavor with a folder can produce unexpected results on Android ๐Ÿค”

Lyokone avatar Jul 18 '22 07:07 Lyokone

I've try the PR using the VGV CLI:

very_good create project --desc "Project" --org "com.lyokone.project" 

It produces the following result:

FileSystemException: Cannot open file, path = 'project/android/app/src/production/google-services.json' (OS Error: No such file or directory, errno = 2)

I feel like matching the name of the flavor with a folder can produce unexpected results on Android ๐Ÿค”

I think Each flavor must have a folder with its name

I tried to fix this by checking if the folder exists before creating androidGoogleServicesJsonFile any suggestions?

salahamassi avatar Sep 04 '22 12:09 salahamassi

any news about this PR?

ulisseshen avatar Nov 22 '22 14:11 ulisseshen

@ulisseshen, @russellwheatley is currently working on this feature in this PR: https://github.com/invertase/flutterfire_cli/pull/132

Lyokone avatar Nov 22 '22 14:11 Lyokone

@ulisseshen, @russellwheatley is currently working on this feature in this PR: #132

thanks for response.

ulisseshen avatar Nov 22 '22 16:11 ulisseshen

Closing as this is no longer necessary. See https://github.com/invertase/flutterfire_cli/pull/132

russellwheatley avatar Dec 28 '22 15:12 russellwheatley