How to Export a Mac .icon File With the Proper Margins
Tahoe Mac app icons are supposed to have margins/padding so that there’s empty space around the edge of the squircle. The opaque pixels don’t touch the edge of the canvas. Icon Composer and Xcode handle this detail for you. You design your icon without having to worry about the margin, and Xcode automatically adds it when compiling your asset catalog.
The issue is, how do you get the proper margin on icon images used in other contexts (documentation, marketing, etc.)? If you export from Icon Composer, it generates PNG files with no margin, so the icon appears too large, even though the outer pixel dimensions are the same. For example, on the SpamSieve screenshots page, the Light icon is generated by Xcode, and the Dark/Clear/Tinted variants are exported from Icon Composer. The difference is substantial.
I posted about this on Mastodon and also found an old post in the Apple Developer Forums, but no one seemed to know the answer.
Back in June, I learned from John Brayton that you don’t have to manually export from the Icon Composer app. It has a command-line tool called ictool
(formerly icontool
) that can convert .icon files to .png. So I have a Makefile that generates all the different sizes and variants for all my apps using commands like this:
"/Applications/Xcode.app/Contents/Applications/Icon Composer.app/Contents/Executables/ictool" AppIcon.icon --export-preview macOS Light 128 128 1 AppIconLight.iconset/icon_128x128.png
Unfortunately, ictool
, like Icon Composer itself, does not add the transparent margin.
I checked Xcode’s build log to see if there were other options it was passing but didn’t find anything. It looks like it’s not using ictool
and instead compiles the icon directly into the asset catalog.
So far, the only solution I’ve found is to actually build my app with Xcode and then extract the icons it generated. You can view the contents of an asset catalog using Samra, but it doesn’t export. Asset Catalog Tinkerer has some export problems—it shows constituents of the .icon as having the same name and only exports one of them—but it’s fine for the purposes of extracting the fully rendered icons.
The method I prefer is to take the .icns file in the .app package and use iconutil
to convert it to a folder of PNGs:
iconutil -c iconset -o AppIcon.iconset AppIcon.icns
Note that, by default, Xcode only generates the .icns file with sizes up to 256px. To get the larger sizes, you need to add to your .xcconfig file:
ASSETCATALOG_COMPILER_STANDALONE_ICON_BEHAVIOR = all
Unfortunately, relying on Xcode to apply the margins only works for the standard (Light) icon. This is the only one that it pre-generates. If you know how to get it to compile Dark/Clear/Tinted variants—or how to properly export those directly without using Xcode—please let me know.
Previously:
- Separate Icons for macOS Tahoe vs. Earlier
- Icon Composer Notes
- macOS Tahoe’s New Theming System
- Samra 1.1
- actool Strips Larger Icon Sizes
1 Comment RSS · Twitter · Mastodon
The command line tool actool was recommended to me to make a car file. But I wasn't able to get this to work, yet.