Skip to content

Commit add377f

Browse files
committed
chore(gen:app-icon): resolve bootsplash source by scale (@4x … logo.png)
Prefer largest available assets/bootsplash PNG; document in README and development.md Made-with: Cursor
1 parent 116f381 commit add377f

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ npx pod-install ios
5151
cp .env.example .env
5252
```
5353

54-
**Launcher icon (optional):** add `assets/app-icon.png` (1024×1024, square), or use the default generator source (`assets/bootsplash/logo@4x.png`), then run `npm run gen:app-icon`. See [docs/development.md](docs/development.md#assets--guards).
54+
**Launcher icon (optional):** add `assets/app-icon.png` (1024×1024, square), or rely on `assets/bootsplash/logo@*.png` (largest available), then run `npm run gen:app-icon`. See [docs/development.md](docs/development.md#assets--guards).
5555

5656
Edit `.env` as needed, then:
5757

docs/development.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ npm run i18n:all
279279
| Command | Description |
280280
|---|---|
281281
| `npm run gen:icons` | Regenerate `assets/icons.ts` from SVGs |
282-
| `npm run gen:app-icon` | Generate **launcher** icons: iOS `AppIcon.appiconset` + Android `mipmap-*` via [`scripts/generate-app-icon.cjs`](../scripts/generate-app-icon.cjs). Source: `assets/app-icon.png` if present, else `assets/bootsplash/logo@4x.png`, else `logo.png`. Flatten background `#111827`. |
282+
| `npm run gen:app-icon` | Generate **launcher** icons: iOS `AppIcon.appiconset` + Android `mipmap-*` via [`scripts/generate-app-icon.cjs`](../scripts/generate-app-icon.cjs). Source: `assets/app-icon.png` if present, else best `assets/bootsplash/logo@*.png` (`@4x``@3x``@2x``@1,5x` `logo.png`). Flatten background `#111827`. |
283283
| `npm run check:icons` | Verify `icons.ts` is in sync (use in CI) |
284284
| `npm run check:imports` | Enforce path alias usage (no deep relative imports) |
285285
| `npm run bootsplash:generate` | Regenerate **native** splash (iOS/Android) via [`scripts/bootsplash-generate.cjs`](../scripts/bootsplash-generate.cjs). Does **not** overwrite `assets/bootsplash/`; writes CLI copies under `assets/bootsplash-generated/` (gitignored). Source: `assets/logo.png` if present, else `assets/bootsplash/logo.png`. Background `#111827`, logo width 160. Then **clean Xcode build** and reinstall — iOS caches the launch screen. |

scripts/generate-app-icon.cjs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* Generate iOS AppIcon.appiconset PNGs + Android mipmap launcher icons from one source.
3-
* Source: assets/app-icon.png (preferred), else assets/bootsplash/logo@4x.png, else logo.png.
3+
* Source: assets/app-icon.png (preferred), else the largest available file under assets/bootsplash/
4+
* (logo@4x → @3x → @2x → @1,5x → logo.png).
45
* Uses sharp (fit: cover, square). Flattens onto #111827 so marketing icon has no transparency.
56
*/
67
const fs = require('node:fs')
@@ -10,8 +11,15 @@ const sharp = require('sharp')
1011

1112
const root = path.join(__dirname, '..')
1213
const APP_ICON = path.join(root, 'assets', 'app-icon.png')
13-
const LOGO_4X = path.join(root, 'assets', 'bootsplash', 'logo@4x.png')
14-
const LOGO_1X = path.join(root, 'assets', 'bootsplash', 'logo.png')
14+
const BOOTSPLASH_DIR = path.join(root, 'assets', 'bootsplash')
15+
/** Prefer largest PNG first (matches typical react-native-bootsplash output names). */
16+
const BOOTSPLASH_SOURCES = [
17+
'logo@4x.png',
18+
'logo@3x.png',
19+
'logo@2x.png',
20+
'logo@1,5x.png',
21+
'logo.png',
22+
]
1523

1624
const BG = { r: 17, g: 24, b: 39 }
1725

@@ -91,12 +99,20 @@ const ANDROID_MAP = [
9199
{ folder: 'mipmap-xxxhdpi', px: 192 },
92100
]
93101

102+
function resolveBootsplashSource() {
103+
for (const name of BOOTSPLASH_SOURCES) {
104+
const p = path.join(BOOTSPLASH_DIR, name)
105+
if (fs.existsSync(p)) return p
106+
}
107+
return null
108+
}
109+
94110
function resolveSource() {
95111
if (fs.existsSync(APP_ICON)) return APP_ICON
96-
if (fs.existsSync(LOGO_4X)) return LOGO_4X
97-
if (fs.existsSync(LOGO_1X)) return LOGO_1X
112+
const fromBootsplash = resolveBootsplashSource()
113+
if (fromBootsplash) return fromBootsplash
98114
console.error(
99-
'app-icon: missing source. Add assets/app-icon.png (1024×1024 recommended) or bootsplash/logo@4x.png / logo.png',
115+
'app-icon: missing source. Add assets/app-icon.png (1024×1024 recommended) or PNGs under assets/bootsplash/ (logo@4x.png logo.png).',
100116
)
101117
process.exit(1)
102118
}

0 commit comments

Comments
 (0)