Mac: Setting the icon the "proper" way

BlitzMax Forums/BlitzMax Tutorials/Mac: Setting the icon the "proper" way

Phish(Posted 2004) [#1]
Copying/pasting the icon in the Finder is not the proper way to do it! And as someone said on the forum, you may have problems with the alpha channel. Here is the way it is meant to be done....

Assuming you have the developer tools installed, create an icns file (see /Developer/Applications/Utilities/Icon Composer.app). Put it in the app's package (right-click on the app, select "Show Package Contents"). Put it in YourApp.app/Contents/Resources/someName.icns.

The next step is to tell the system how to find the icon. In YourApp.app/Contents/ you need an "info.plist" file. I'd just steal one from another app and change the values in it. If you double click the info.plist, it should open automatically in "Property List Editor" which is easier than reading XML. The important key of course is "CFBundleIconFile", which you set to whatever you had as someName.icns. I'm not sure, but you should probably delete any keys which aren't relevant or you don't understand about for your app.

Finally, to make sure it has worked, show the Get Info window for your app, click the icon in the top left, and press backspace. This will make sure that any temporary icon the system has cached will be removed, putting it back to the "default" - i.e. what you just set it to what it is meant to be.

Voila, you have changed the icon properly and permanently. Now we just need BlitzMax to do it all automatically. It would be nice we didn't have to delve into application packages and deal with the info.plist file.

This is all based on my developing experience, so if anyone has any other hints or would like to point out a mistake, please do!


JaviCervera(Posted 2004) [#2]
Really cool. This post should be made sticky.


Koekelas(Posted 2005) [#3]
Thank you. You saved my day.


Nicolas.


Will(Posted 2005) [#4]
Doesnt work for me. I tried removing all, some, or none of hte original Plist values besides changing the "CFBundleIconFile" to reference my own file in the Resources folder - still doesnt work. Any ideas?


Rozek(Posted 2007) [#5]
Hello,

if you already have icons in your application (which is the case after successfully compiling and linking a BlitzMax program) it is sufficient to replace the .icns file in your application bundle with the one you want.

It works fine for my "BlitzLua" program - although there are two issues left:

- how can that process be done automatically? (for Windows, a simple "import" of an icon file is sufficient)
- how can data files be "associated" with a BlitzMax program (and get a proper icon, too)?


jhocking(Posted 2007) [#6]
I would imagine the best way to associate icon files with a bmx would be the same way you do it with any other data files, by specifying in the code. So like add a command AppIcon("filename.bmp") to have the compiler use that image as the icon for the built application.