fluttercommunity / flutter_launcher_icons

Flutter Launcher Icons - A package which simplifies the task of updating your Flutter app's launcher icon. Fully flexible, allowing you to choose what platform you wish to update the launcher icon for and if you want, the option to keep your old launcher icon in case you want to revert back sometime in the future. Maintainer: @MarkOSullivan94
https://pub.dev/packages/flutter_launcher_icons
MIT License
1.98k stars 393 forks source link

[BUG] launching with flavor (-f) option generates icons for ALL flavors instead of the desired only #215

Open WieFel opened 3 years ago

WieFel commented 3 years ago

:information_source: Info

Version: v0.8.0

:speech_balloon: Description

I have set up 3 flavors in my app: flavor1, flavor2 and flavor3. For flavor1 and flavor2 I already had generated the launcher icons beforehand.

Now I only want to generate icons for flavor3 only. I created an own yaml file for flavor3 called flutter_launcher_icons-flavor3.yaml. I execute the following command in the terminal:

flutter pub run flutter_launcher_icons:main -f flutter_launcher_icons-flavor3.yaml

and get the output

Flavor: flavor3
• Building iOS launcher icon for flavor3

Flavor: flavor2
• Building iOS launcher icon for flavor2

Flavor: flavor1
• Building iOS launcher icon for flavor1

✓ Successfully generated launcher icons for flavors

The previously generated icons of flavor1 and flavor2 are overwritten. However, I would only expect that icons for flavor3 are generated and the other two are left untouched...

:scroll: Pubspec.yaml

My flutter_launcher_icons-flavor3.yaml file for flavor3:

flutter_icons:
  android: false
  ios: true
  image_path: "assets/logos/flavor3.png"
personalizedrefrigerator commented 3 years ago
Future<void> createIconsFromArguments(List<String> arguments) async {
  // ... omitted lines ...

  // Flavors manangement
  var flavors = getFlavors();
  var hasFlavors = flavors.isNotEmpty;

  // Load the config file
  final Map<String, dynamic> yamlConfig =
      loadConfigFileFromArgResults(argResults, verbose: true);
 /*
 -----------------------------------------------------------------------------------
  I think the error is here. It looks like if and only if !hasFlavors,
  is the if branch run (and thus yamlConfig used). Otherwise, 
  it generates icons from all flavor files.

  There should probably be a check here. If the -f argument
  is given, it should go into the if branch, even if flavors are present.
--------------------------------------------------------------------------------------
*/

  // Create icons
  if ( !hasFlavors ) {
    try {
      createIconsFromConfig(yamlConfig);
    } catch (e) {
      stderr.writeln(e);
      exit(2);
    } finally {
      print('\n✓ Successfully generated launcher icons');
    }
  } else {
    try {
      for (String flavor in flavors) {
        print('\nFlavor: $flavor');
        final Map<String, dynamic> yamlConfig = loadConfigFile(flavorConfigFile(flavor), flavorConfigFile(flavor));
        await createIconsFromConfig(yamlConfig, flavor);
      }
    } catch (e) {
      stderr.writeln(e);
      exit(2);
    } finally {
      print('\n✓ Successfully generated launcher icons for flavors');
    }
  }
}

The issue seems to be in createIconsFromArguments (see inserted comment). I think this will be fixed with PR #155...

WieFel commented 3 years ago

@personalizedrefrigerator thank you! I hope that your PR will be merged soon 😉

rockgecko-development commented 3 years ago

I consider this a feature actually :) It generates icons for all flavors at once, so I don't need to invoke it multiple times

WieFel commented 3 years ago

But if you have multiple flavors and only want to generate the icons for one single flavor, it is inconvenient if the others are replaced as well.

raulmabe commented 3 years ago

I agree with @WieFel , running a single flavor is a must. Additionally, a flag could be added to run all flavors at once.

WieFel commented 3 years ago

Still the same problem. Any news on this?

AlexanderThiele commented 2 years ago

no, it's still the same. for the current active version at least.

obiwanzenobi commented 6 months ago

Is there any workaround for this?