Reputation: 2882
For starters my build for a "normal" (non-tray) app works fine with electron-packager and this command
npx electron-packager . --overwrite --plaorm=darwin --arch=x64 --icon=aicons/1024.icns --prune=true --out=release-builds
I have recently re-factored my code so now is a tray app
so I have
tray = new Tray('icons/elektro.png')
tray.setToolTip('elektro')
This works fine with npm start but when I build the .app using electron-packager I get this error:
Uncaught Exception:
TypeError: Error processing argument at index 0, conversion failure from icons/elektro.png
at App.<anonymous> (/Users/gurugeek/elektro/release-builds/elektro-darwin-x64/elektro.app/Contents/Resources/app/main.js:48:10)
at App.emit (events.js:205:15)
I assume the problem relates to the .png used for the tray icon. If I change it to a .icns format it won't work anymore with npm start. Any idea how to fix this ?
I am using electron 6
Upvotes: 1
Views: 973
Reputation: 2882
Alright the issue is related to the path. It seems trivial but the .app file just dies without any error in most cases. This issue is very poorly documented everywhere so I leave it here for whomever finds the same issue:
const path = require('path');
var iconPath = path.join(__dirname, '/icons/elektro.png') // your png tray icon
let trayIcon = nativeImage.createFromPath(iconPath);
// if needed resize to 16x16 but mac also accepted the 24 icon
// trayIcon = trayIcon.resize({
// width: 16,
// height: 16
// });
tray = new Tray(trayIcon)
Upvotes: 1