How to set the app icon using electron-forge package on Mac?
Asked Answered
B

2

20

Can somebody please tell me the instructions for using a custom icon, when compiling an electron app (on mac) when using electron-forge package? Using --icon gives me an error:

error: unknown option `--icon'

What am I missing?

Bromate answered 22/5, 2017 at 21:40 Comment(0)
B
56

Figured it out. Configure the path to your icon in your package.json.

Electron-Forge v5:

{
  ...
  "config": {
    "forge": {
      ...
      "electronPackagerConfig": {
        "icon": "path/to/icon.icns"
      },
      ...
    }
  }
}

Electron-Forge v6:

{
  ...
  "config": {
    "forge": {
      ...
      "packagerConfig": {
        "icon": "path/to/icon.icns"
      },
      ...
    }
  }
}
Bromate answered 23/5, 2017 at 11:21 Comment(11)
Thanks! Might be obvious to others, but this doesn't change the icon when running in electron-forge startRoxane
I can't find the documentation for this anywhere- can someone point to some (hopefully always-current) documentation link? (the larger question is: what are the parameters/constraints of this icon? etc...)Quean
@Quean electronforge.io/configuration#packager-config although it is now documenting Version 6.Neumeyer
Hi all. I've updated my answer to show instructions for both v5 and v6.Bromate
Is this solution cross-platform? It seems macOS specific? Since package.json is shared by all platforms. I wonder how this could extend to Windows.Capriccio
Apparently, the electron app do not accept .icns. they only accept .ico icons.Footworn
@TengBangWei windows icons use .ico and macOS uses .icnsCarolanncarole
Just remove the extension from the "icon" property as pointed out by @cris answer. And make sure you do have the proper files in place, e.g. icon.icns, icon.ico and icon.png.Neiman
Is this a relative path to the config file?Polymerization
@Polymerization yeah, that's what I have: github.com/will-stone/browserosaurus/blob/…Bromate
@WillStone, thanks, ya, it ended up working for me after a reboot. Looks like windows held the old icons around.Polymerization
G
8

Per the Options.icon documentation:

If the file extension is omitted, it is auto-completed to the correct extension based on the platform, including when platform: 'all' is in effect

Given that, set the value without extension:

"icon": "./assets/icon"

This is confirmed to work on both Windows and Mac.

Gainor answered 26/5, 2021 at 9:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.