Debugging Services in OS X
June 08, 2011

When you’re developing an application that provides Services in OS X, you sometimes need to change the definitions of the services.

These are stored in the info.plist in your application, but just changing it and rebuilding the application isn’t enough, you also have to force the system to re-index the services so that it spots your changes.

You can do this by calling NSUpdateDynamicServices() in your application, or by running /System/Library/CoreServices/pbs on the command line.

I recently came up against a problem with this though. When pbs scans, it seems to just pick up the definitions from the first version of a given application. If you’re developing, you often have multiple copies lying around, and you don’t seem to have any control over which version pbs will come across first.

I’m guessing that pbs simply scans your volumes in alphabetical order. I had an issue where it was picking up an old version of an app in the “Archived Applications” section of the “Derived Data” folder on a different partition, before finding the version that I had just built.

I’ve found a simple fix which worked for me - simply move the new application into /Applications temporarily, and run a scan. This seemed to be enough to get pbs to pick up the correct app. Whether it will always work, I’m not sure, and it’s a pain to have to keep copying it there if making multiple changes, but luckily the services settings are something that you tend not to have to tweak very often.