asticode / go-astilectron-bundler

Bundle your Astilectron app with ease
MIT License
127 stars 67 forks source link

bundle tray icon image into application #57

Closed nikhilsaraf closed 4 years ago

nikhilsaraf commented 4 years ago

I'm trying to bundle the image for the tray icon with my deployment, but it fails to copy the tray icon image into the bundled file (MacOS).

This gives an error when trying to start the app because the tray icon is missing in the packaged binary.

I'm certain this should be possible but just couldn't get it to work. I even see the byte-version of the image in the bind_*.go files.

nikhilsaraf commented 4 years ago

^@asticode

asticode commented 4 years ago

are you using the bootstrap ?

nikhilsaraf commented 4 years ago

Yes

khuderm commented 4 years ago

at least the auto generated plst file is ignoring icon paths

<key>CFBundleIconFile</key>
        <string>`+b.appName+filepath.Ext(b.pathIconDarwin)+`</string>
nikhilsaraf commented 4 years ago

To get around this issue I'm writing out the icon file (png) to disk from the bind file that is generated by the bundler (link to source code). Then I pass the path of that generated icon file to the TrayOptions (link to source code).

If there's a better way to do this such as specifying which files in the resources directory we also want included in the final package that would be very helpful

asticode commented 4 years ago

@khuderm This section of the plst file is for the App icon, not the Tray icon. And no need to take the path into account since the icon has been moved by the bundler.

@nikhilsaraf The path you provide for the Tray is relative to the app directory. As your tray icon must be in the resources folder, the path you set in the bootstrap Options should be resources/path/to/icon.png so in your case resources/kelp-icon@1-8x.png. Does that work better ?

nikhilsaraf commented 4 years ago

@asticode that didn't work for me and I got the same error because it never copied resources/kelp-icon@1-8x.png into the final resources folder.

asticode commented 4 years ago

Does the app icon gets copied ? resources/kelp-icon@2x.png in your case ?

nikhilsaraf commented 4 years ago

@asticode yes that gets copied, probably because it’s specified in the bundled.json file (source code)

asticode commented 4 years ago

1 ) Can you run ls -l on your resources folder in your source project and paste results here ? 2) Can you run ls -l on your resources folder in your app located in /path/to/name.app/Contents/MacOS/resources and paste results here as well ? 3) Can you enable astilog at the top of your main function:

flag.Parse()
astilog.FlagInit()

run /path/to/name.app/Contents/MacOS/name -v and paste logs here? 4) Run the bundler with the -v flag and paste logs here?