# `launcher_icons`

| Package | Kind | Provides the role | Needs | Choose with |
| --- | --- | --- | --- | --- |
| [`smf_launcher_icons`](https://pub.dev/packages/smf_launcher_icons) | infrastructure | App icon | nothing | `-m launcher_icons` |

`launcher_icons` makes the icon of the app with [flutter_launcher_icons](https://pub.dev/packages/flutter_launcher_icons): an opaque icon on iOS and an adaptive icon with a themed variant on Android, in place of the logo of Flutter. All [flavors](https://doc.saymyframe.com/guides/flavors.md) of the app share the icon. To replace the images, see [App icon and splash screen](https://doc.saymyframe.com/guides/app-icon-and-splash.md).

## What it adds to the app

| In the app | What it is |
| --- | --- |
| `flutter_launcher_icons: ^0.14.4` in the dev dependencies | The tool. No code of the app imports it. |
| `assets/branding/icon.png` | 1024 by 1024 and opaque, for iOS and older versions of Android. It shows the mark of Say My Frame in cream on green. |
| `assets/branding/icon_foreground.png` | 1024 by 1024, the same mark on a transparent background, for the adaptive icon of Android |
| `flutter_launcher_icons.yaml` | How the tool makes the icon, with the colour `#0F3326` behind the mark on Android, and the second image as the themed icon too |
| `tool/update_app_icon.dart` | The script that runs the tool, and that you run again after a change |
| The section "Launcher icons" of the README | What the images show, and the command |

Whichever module provides it, the role adds the section "App icon" of the README. The app does not bundle the images.

In the [guide for coding agents](https://doc.saymyframe.com/guides/coding-agents.md) of the app, the role names the sources under "App icon". The module adds the command, and that an agent neither runs the tool itself nor adds a file for a flavor.

## After generation

The module runs `dart tool/update_app_icon.dart` once the app has its packages. A run in a terminal asks first, with Enter for yes:

```text
? Making the app icon from assets/branding (dart tool/update_app_icon.dart), for launcher_icons. Run it now? (Y/n)
```

A run without a terminal runs it too. When the tool fails, you still get the app, with the logo of Flutter, a warning and the command to run later.

Run the script again after you change an image or `flutter_launcher_icons.yaml`, and commit what changed under `android/` and `ios/`:

```bash
dart tool/update_app_icon.dart
```

## Why a script

flutter_launcher_icons 0.14.4 writes the name of the icon into every build setting of the Xcode project whose name has `ASSETCATALOG`. One of those settings, `ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS`, takes `YES` or `NO`. The script gives that setting its value back, or `YES` after a run of the tool alone. So use the script rather than `dart run flutter_launcher_icons`.

## Choosing it

`smf create` asks which module provides the app icon, and the answer may be none. To choose it without the question:

```bash
smf create my_app -m launcher_icons
```
