Last Updated: February 25, 2016
·
1.18K
· not-only-code

Adding icons to orphan file types in OSX

If you ever come across this...

Picture

That's because this file type is an 'icon orphan' from his application.

Every application manage his file types in info.plist xml file inside Contents package

Lets to add another type extension to our application

  • Navigate to Applications folder and right-click in your application icon
  • Click Show Contents Package
  • Navigate to /Contents/ and open info.plist ( Mac OSX has an application named Proper List Editor that manage xml files, if you not, open it with your code editor )
  • If you take a look, there is a node called Document types, something like this

That means this application supports .css files with this extensions

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>css</string>
        </array>
        <key>CFBundleTypeIconFile</key>
        <string>doc-css</string>
    </dict>
</array>

And the icon for this filetype is doc-php.icns always inside the folder Resources.

Then we can add more file extensions:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>css</string>
            <string>less</string>
            <string>scss</string>
            <string>sass</string>
        </array>
        <key>CFBundleTypeIconFile</key>
        <string>doc-css</string>
    </dict>
</array>

Save the info.plist document, exit from the application and restart Finder
in Terminal

$ sudo killall Finder

If this doesnt work move the application to desktop, open it, close it, and move again to applications folder.