Skip to content

Commit c2b5649

Browse files
0xlauerickzhao
andauthored
docs: enhance icon generation guide with macOS support (#254)
Co-authored-by: Erick Zhao <erick@hotmail.ca>
1 parent c23f806 commit c2b5649

1 file changed

Lines changed: 57 additions & 8 deletions

File tree

guides/create-and-add-icons.md

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: >-
88

99
## Generating an icon
1010

11-
Generating your icon can be done using various conversion tools found online. It is recommended to start with a 1024x1024px image before converting it to various sizes.
11+
Generating your icon can be done using various conversion tools found online. It is recommended to start with a 1024x1024px image before converting it to the formats required by each platform.
1212

1313
### Supporting higher pixel densities
1414

@@ -33,19 +33,23 @@ The following suffixes for DPI are also supported:
3333

3434
The recommended file formats and icon sizes for each platform are as follows:
3535

36-
| Operating system | Format | Size |
37-
| ---------------- | ------- | ---------------------------------------------- |
38-
| macOS | `.icns` | 512x512 pixels (1024x1024 for Retina displays) |
39-
| Windows | `.ico` | 256x256 pixels |
40-
| Linux | `.png` | 512x512 pixels |
36+
| Operating system | Format | Size / notes |
37+
| ---------------- | --------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
38+
| macOS | `.icns` (or `.icon`) | Use a 1024x1024 source image. Keep an `.icns` file for compatibility, and add an Icon Composer `.icon` file for macOS 26+. |
39+
| Windows | `.ico` | 256x256 pixels |
40+
| Linux | `.png` | 512x512 pixels |
4141

4242
{% hint style="warning" %}
4343
On Windows, ensure that your `.ico` file is exported from an image editor that supports the format (such as [GIMP](https://www.gimp.org/)). Renaming a `.png` file into `.ico` will result in a `Fatal error: Unable to set icon` error.
4444
{% endhint %}
4545

46+
{% hint style="info" %}
47+
`@electron/packager` supports macOS Icon Composer files as of [`@electron/packager` v18.4.0](https://github.com/electron/packager/releases/tag/v18.4.0). To support both macOS 26+ and earlier releases, provide both an `.icns` file and a `.icon` file.
48+
{% endhint %}
49+
4650
## Setting the app icon
4751

48-
### Windows and macOS
52+
### Windows
4953

5054
Configuring the path to your icon can be done in your Forge configuration.
5155

@@ -62,7 +66,52 @@ module.exports = {
6266
{% endcode %}
6367

6468
{% hint style="success" %}
65-
Forge will automatically add the correct extension for each platform, so appending `.ico` or `.icns` to the path is not required.
69+
When you provide a single icon path, Electron Packager will automatically add the correct platform extension, so appending `.ico` here is not required.
70+
{% endhint %}
71+
72+
After the config has been updated, build your project to generate your executable with the Make command.
73+
74+
### macOS
75+
76+
If you only need the traditional macOS icon format, you can continue to provide a single `icon` path in `packagerConfig`:
77+
78+
{% code title="forge.config.js" %}
79+
```javascript
80+
module.exports = {
81+
// ...
82+
packagerConfig: {
83+
icon: '/path/to/icon' // .icns will be inferred
84+
}
85+
// ...
86+
};
87+
```
88+
{% endcode %}
89+
90+
If you need one configuration that supports both macOS 26+ and earlier macOS releases, provide both an `.icns` file and an `.icon` file:
91+
92+
{% code title="forge.config.js" %}
93+
```javascript
94+
module.exports = {
95+
// ...
96+
packagerConfig: {
97+
icon: [
98+
'/path/to/icon.icns',
99+
'/path/to/icon.icon'
100+
]
101+
}
102+
// ...
103+
};
104+
```
105+
{% endcode %}
106+
107+
Electron Packager will use the `.icns` file on macOS versions earlier than 26, and the `.icon` file on macOS 26 and later.
108+
109+
{% hint style="warning" %}
110+
Packaging an `.icon` file currently requires macOS 26 or later and Xcode 26 or later because Electron Packager uses Apple's `actool` tool to compile the Icon Composer asset.
111+
{% endhint %}
112+
113+
{% hint style="info" %}
114+
When you provide multiple macOS icon files, include the file extensions explicitly so Packager can distinguish the `.icns` and `.icon` inputs.
66115
{% endhint %}
67116

68117
After the config has been updated, build your project to generate your executable with the Make command.

0 commit comments

Comments
 (0)