Setting dock icon on mac?

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Setting dock icon on mac?

Postby DanKegel » Thu Oct 26, 2017 4:12 pm

What's the right way to set the dock icon on a mac app that uses CEF but doesn't use a nib file?

Calling [NSApp setApplicationIconImage:foo] in applicationDidFinishLaunching
works great for plain cocoa apps, and works when you launch my test app
via 'tiny.app/Contents/MacOS/tiny'... but when you launch it via 'open tiny.app',
the dock icon is the default one. To fix that case, I had to do it in an OnAfterCreated
handler, and the default icon bounces for a bit during launch before this fires
and sets the right icon. Is there a better way?

To see what I'm talking about:
git clone https://github.com/dankegel/tinycef.git
cd tinycef
sudo make prefix
make
tiny.app/Contents/MacOS/tiny # Observe dark circle dock icon, thanks to applicationDidFinishLaunching
(quit)
open tiny.app # Observe dark circle dock icon, thanks to OnAfterCreated, but a little late.

This app doesn't even have an Info.plist, it's trying to be really minimal. I have a funny feeling someone's going to say "Put the icon in the Info.plist, you fool" :-)
DanKegel
Mentor
 
Posts: 59
Joined: Fri Nov 08, 2013 12:46 pm

Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 40 guests