Jeremy Friesner
Jeremy Friesner

Reputation: 73279

How to set an icon for an executable that isn't the app's main CFBundleExecutable?

I have some MacOS client/server software that originally installed as a folder containing two separate .app folders; one for the client, and one for the server.

That worked fine, except that it meant that I had to include a separate copy of every bundled shared library in each *.app/Contents/Frameworks sub-folder; and given that both apps have a Qt-based GUI, that was a substantial amount of overhead.

Someone suggested that instead of shipping the two programs as separate .app folders, I simply move the server's executable file (TheServer.app/Contents/MacOS/TheServer) into the client's Resources folder (TheClient.app/Contents/Resources/) and then add a "Launch Server" button to the client GUI that launches TheClient.app/Contents/Resources/TheServer as a child process when clicked.

I did that, and that also works well, and reduces my application's .pkg size by about 25 megabytes.

The only downside is that now when TheServer runs, its icon in the Dock is a generic Terminal icon (see attached screenshot) rather than its intended custom icon; presumably this is because TheServer no longer has an associated Info.plist file in which to declare its CFBundleIconFile attribute specifying where its .icns file is.

My question is, is there any way to remedy this situation and allow TheServer's GUI to have its custom Dock icon again? Or am I just out of luck here?

generic Terminal icon

Upvotes: 0

Views: 206

Answers (1)

myzz
myzz

Reputation: 11

One possibility that works with raw binaries without bundles is to simply replace the Dock icon programmatically when the program starts:

[NSApp setApplicationIconImage:nsImage];

This way you don't really even need an icon file at all, as you can create the NSImage programmatically if you feel like it.

Upvotes: 1

Related Questions