Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set icon of non app mac os x bundle

How to set icon for bundle which is not an app? I tried using CFBundleIconFile, but it doesn't work (though if I just change bundle extension to .app, icon is changed to desired one). Is there another key, or the only way is to set icon for directory? If so, is there already some script to do this from command line (Xcode run script)?

like image 714
tig Avatar asked Nov 06 '22 03:11

tig


1 Answers

Visual documentation of the process of copying and pasting an icon in the Finder

If you need to do it from CLI... It's a bit more involved...

First, you need to add a CFBundleIconFile string to your bundle's

YourThing.bundle/Contents/Info.plist

Here's where the developer gets to specify a custom icon for the bundle. This key contains the name of a file in the bundle's Resources folder that holds the icons. TextEdit keeps its icon in a file called Edit.icns file, but there's no rule about what the name of the file must be.

That said, you either need an ICNS file, or can follow these instructions from this Utility (which includes its source code) that generates ICNS's from image files via the command line..

$ ./makeicns 

Usage: makeicns [k1=v1] [k2=v2] ...

Keys and values include: 512: Name of input image for 512x512 variant of icon 256: Name of input image for 256x256 variant of icon 128: Name of input image for 128x128 variant of icon 32: Name of input image for 32x32 variant of icon 16: Name of input image for 16x16 variant of icon in: Name of input image for all variants not having an explicit name out: Name of output file, defaults to first nonempty input name, but with icns extension

Examples:

  makeicns -512 image.png -32 image.png

Creates image.icns with only a 512x512 and a 32x32 variant.

  makeicns -in myfile.jpg -32 otherfile.png -out outfile.icns

Creates outfile.icns with sizes 512, 256, 128, and 16 containing data from myfile.jpg and with size 32 containing data from otherfile.png.

like image 152
Alex Gray Avatar answered Nov 09 '22 17:11

Alex Gray