Apple - How come Dropbox gets an icon in Finder sidebar?

As you've noticed, recent versions of OS X only display generic folder icons in the sidebar. So why does Dropbox get special treatment?

The short answer is that Dropbox uses undocumented API to accomplish this. In non-technical speak, it's a special hack that's installed by the Dropbox application.


Some curious folks on StackOverflow found the specific mechanism used by Dropbox: good ol' mach_inject. The same bundle provides both the toolbar item and the sidebar icon.

If you're curious, the resource files live here (at least, on my system):

/Library/DropboxHelperTools/Dropbox_u502/DropboxBundle.bundle/Contents/Resources

Clearly, Dropbox goes to great lengths in order to integrate seamlessly into the Finder. Lacking similar treatment, other ordinary folders have only generic icons in the sidebar.


Edit 10/1/2015: As of Yosemite (10.10), there is a new, sanctioned Finder Sync API for integration, as doovers points out in another answer. In El Capitan (10.11), System Integrity Protection will not permit the old mach_inject-style approach.


According to the documentation for the Finder Sync Extension:

You can also use the extension point’s API to add a toolbar button to the Finder window or a sidebar icon for the monitored folder.

I would guess this is what Dropbox uses to achieve this and some/all the other functionality facilitated by this extension. For example you can also:

  • Register a set of folders to monitor.
  • Receive notifications when the user starts or stops browsing the content of a monitored folder. For example, the extension receives notification when the user opens a monitored folder in the Finder or in an Open or Save dialog.
  • Add, remove, and update badges and labels on items in a monitored folder.
  • Display a contextual menu when the user Control-clicks an item inside a monitored folder.
  • Add a custom button to the Finder’s toolbar.

Edit:

As Mugen mentions below, El Capitan will not allow code injection making FinderSync the only option going forward. With FinderSync only available from 10.10+ the best option would be to case it like:

if (floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_10) { ... }

Install the latest Xtra Finder App from - http://www.trankynam.com/xtrafinder/

Turn on "Show Colorful Icons in the SideBar" It is located below a text box of "Max Width"

For Other Icons in Sidebar

Replace the files here : /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ folder contains the used grey ICNS in addition to [unused] 1024x1024 color ICNS files. Each ICNS files must support the following sizes:

  • 16x16 72 DPI
  • 18x18 72 DPI
  • 32x32 144 and 72 DPI
  • 36x36 144 DPI
  • 64x64 144 DPI

If you have added a custom folder to the sidebar, you can change it's icon too. Let us say that the folder name is called "Softwares" Prepare an ICNS file with the name SidebarSoftwares.icns in the above mentioned directory.

Basically the icns file needs to be named SidebarFoldername.icns where Sidebar Remains constant and you input the relevant foldername.

For DropBox

Apply ICNS file to /Users/admin/Dropbox /Applications/Dropbox.app /Applications/Dropbox.app/Contents/Resources/box.icns (need to replace this file with the one you want)

DropBox Finder SideBar Icons

Navigate to /Library/DropboxHelperTools/Dropbox_u502/DropboxBundle.bundle/Contents/Resources

Here you need to replace the following: toolbar.tiff (32x32 pixels 72 DPI)

sidebar.tiff (64x64 pixels 72 DPI)

contextmenu.tiff (32x32 pixels 72 DPI)

toolbar_large.png (19x19 pixels 72 DPI)

sidebar_blue.png (16x16 pixels 72 DPI)