macosinstallationiconspackagepackagemaker

How can I give a Flat Package (.pkg) an icon which is seen on different computers?


I know it's possible to give a .pkg file an icon which is seen on my Mac, but I want to make it so it's seen by everyone who might get this package.

I've seen this before so I know it's possible, but when opening a .pkg which does have an icon set the way I want it I can't see anything which is pointing to an icon so I'm stumped. Apple aren't exactly helpful with this kinda stuff.

Any help is appreciated!


Solution

  • Custom icons for files live in the icns -16455 resource. You can simply copy and paste using into the Finder's Info window to set an icon, or you can automate the process of incorporating an .icns file using Rez, like this:

    echo "read 'icns' (-16455) \"foo.icns\";" | Rez -o foo.pkg ; SetFile -a C foo.pkg
    

    Note that in newer Xcode revisions, Rez and SetFile are located inside the Xcode bundle in Contents/Developer/Tools; you can also locate them with xcrun.

    To distribute your flat package with its icon intact, you will need to compress/encode it with a tool that will include its resource fork, such as Apple's tar, CPIO or Zip implementations (the latter two either via Archive Utility or ditto), or place it in a disk image.