I was searching for the best way to add a new file extension type (.xyz) and associate an icon to all files of that kind in SnowLeopard.
It depends on whether you want a specific application to open these file types, or leave them unassociated.
If you want them to open with a specific application, you select that application in one of these files' Get Info dialog and check Always Open With in the selection dialog.
Now this file extension is associated with that application, but probably has a generic icon. The icon is the associated application's responsibility, so we need to change it.
Now you need to edit your application's bundle:
Right-click the application to handle these file extensions and select Show Package Contents. Navigate to
Contents, and edit
Info.plist. You might need Property List Editor, which is part of Apple's developer tools. If you're lucky, it's an XML format. Edit this file's
CFBundleDocumentTypes and add the following for the extension
<key>CFBundleDocumentTypes</key> <array> <!-- keep the other entries! --> <dict> <key>CFBundleTypeExtensions</key> <array> <string>foo</string> </array> <key>CFBundleTypeIconFile</key> <string>FooDocument</string> <key>CFBundleTypeName</key> <string>Foo Document</string> <key>CFBundleTypeRole</key> <string>Viewer</string> </dict> </array>
Save the file.
For the icon, you need to create a file in
FooDocument.icns. You can create
icns files using Preview or specialized utilities.
You will need to repeat this every time you update the application.
If you don't want the files to open with a specific application, you can create a new "dummy" application bundle (it doesn't even need to be able to launch), where you place the icon and add the
CFBundleDocumentTypes information from above.