flutter_launcher_icons icon indicating copy to clipboard operation
flutter_launcher_icons copied to clipboard

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

Open WieFel opened this issue 5 years ago • 9 comments

: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"

WieFel avatar Nov 12 '20 08:11 WieFel

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...

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

WieFel avatar Nov 13 '20 22:11 WieFel

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

rockgecko-development avatar Jan 13 '21 03:01 rockgecko-development

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.

WieFel avatar Jan 16 '21 11:01 WieFel

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

raulmabe avatar May 17 '21 12:05 raulmabe

Still the same problem. Any news on this?

WieFel avatar Aug 12 '21 09:08 WieFel

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

AlexanderThiele avatar Feb 21 '22 13:02 AlexanderThiele

Is there any workaround for this?

obiwanzenobi avatar Jan 26 '24 00:01 obiwanzenobi