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.