I'm having an issue setting the icon for my Electron app in two different ways:
<strong>Non-Packaged (Running the app via terminal)</strong>
My main.js does specify an 'icon' value, pointing to the icon file, but it does not apply.
<strong>Packaged (with electron-packager)</strong>
My package.json file specifies the 'icon' key, pointing to the icon file, and I have the .icns (Mac) file in the <em>build</em> directory. I used electron-packager to build the app, but the icon is not applied, the default electron icon is used instead.
Not sure what I'm doing wrong here, everything appears correct.Answer1:
There is a good tutorial here:<ul><li><a href="https://www.christianengvall.se/electron-app-icons/" rel="nofollow">https://www.christianengvall.se/electron-app-icons/</a></li> </ul>
Follow the steps but make sure you don't skip anything.
This is also a relevant issue on GitHub:<ul><li><a href="https://github.com/electron-userland/electron-builder/issues/289" rel="nofollow">https://github.com/electron-userland/electron-builder/issues/289</a></li> </ul>
More links here:<ul><li><a href="https://discuss.atom.io/t/changing-electron-app-icon-and-information/18631" rel="nofollow">https://discuss.atom.io/t/changing-electron-app-icon-and-information/18631</a></li> </ul>Answer2:
You can add this script to package.json and it works perfectly fine. Mostly its because of the path issues.
"package-mac": "electron-packager . --overwrite --platform=darwin --arch=x64 --icon=assets/icons/mac/icon.icns --prune=true --out=release-builds",