Developing an application for Mac OS, sooner or later you’ll want to add an icon to it. And Mac OS uses Apple’s own format for application icons - Apple Icon Image format - files with
.icns extension. But how does one create such a file?
It is actually not so hard, but there are some tricky moments. I’ll cover those and as a bonus I’ll show you how to use
.icns icon in Qt-based application (deadly simple).
There is an out-of-the-box Mac OS tool for such conversion - iconutil (documentation for which is nowhere to find at Apple’s website, so this brief
man page is all we have).
Best Mac App
I just “finished”1 an app that runs on iOS and Android using Qt 5.6. It’s written mostly in C and QML. Yes, I’m skipping other platforms, like Windows Phone, Windows Desktop, Mac.
Intelligent character recognition software free download. However, you cannot just take a random PNG and feed it to
iconutil . I mean, you can, but it will give you the following error:
Because
iconutil takes only specially named folders. Modify running apps in mac dock. Just how am I supposed to know about that? And it shows similar short and useless error messages for other things it doesn’t like. For example, here’s an output for the situation when files inside iconset folder are not named “properly” or have “wrong” dimensions:
Go figure. Adobe photoshop cs6 download for mac free.
After a set of trials and browsing the internet I found out (hopefully) all the requirements:
Correct dimensions can be found in Apple Guidelines. So it’s 5 different dimensions, but actually 10 “physical” files as each dimension is represented twice (you’ll see why). And these files have to be named according to the following format:
So here’s the full list of proper filenames:
At the same time, I’ve got a commit to my script, and this commit adds more sizes, which supposedly solves some
missing size error. I never got such an error, so even though I accepted the commit, I won’t add those changes to the article.
Script to automate the process
But that’s rather boring to create all those files manually in some graphics editor, right? So let’s use sips utility (although, I recommend using ImageMagick, as it gives better quality results):
Better, but still - we have to run it 10 times. So let’s write a Python script for that:
The full script is published here. World of final fantasy strategy guide download. Mac heart filter app.
As an example, I prepared a square picture with a resolution of 2048x2048 and 150 pixel per inch, so there is plenty room to prevent upscaling:
Pass picture path to the script like that: Free andis btf 22913 user manual.
The script will:
Here’s how the final
apple.icns looks like in Preview:
![]()
Mac app finder shortcut password. So everything from that folder is bundled into one file.
And now the bonus part - how to use
.icns as an icon for a Qt-based application.
Qt Set Icon
As I said, it’s deadly simple: put
apple.icns into your Qt project folder and add the following line into your-project.pro :
![]() Top Mac AppComments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |