Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add Contents.json file to icon set #266

Open
vinifig opened this issue Jun 3, 2024 · 2 comments
Open

Add Contents.json file to icon set #266

vinifig opened this issue Jun 3, 2024 · 2 comments

Comments

@vinifig
Copy link
Contributor

vinifig commented Jun 3, 2024

Expected with contents.json:

image image

Actual without contents.json:
image

Causing:
image

@dragongesa
Copy link

+1

@vinifig
Copy link
Contributor Author

vinifig commented Jun 4, 2024

Temporarily I've made this script with many more to adjust flavorizr to our internal processes and necessities:

import 'dart:io';

import 'package:flutter_flavorizr/src/parser/parser.dart';
import 'package:yaml/yaml.dart';

Future<void> main() async {
  await _fixLaunchIcons();
}

List<FlavorizrData> getFlavorizrData() {
  Parser parser = const Parser(
    pubspecPath: 'pubspec.yaml',
    flavorizrPath: flavorizrPath,
  );

  final config = parser.parse();
  return config.flavors.entries.map(_extractFlavorData).toList();
}


Future<void> _fixLaunchIcons() async {
  final flavors = getFlavorizrData();
  final contentsJSON = await File(
    'ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json',
  ).readAsString();
  for (final flavor in flavors) {
    final flavorName = flavor.name;
    await File(
      'ios/Runner/Assets.xcassets/${flavorName}AppIcon.appiconset/Contents.json',
    ).writeAsString(contentsJSON);
  }
}

if it's of any help to any of you, run it after running flavorizr (be it on the ci or your local machine that will solve your problem whilst it's not fixed on the lib)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants