Development notes
This page lists some assorted notes I accumulated while writing the Email Address Sort Service.
Bibliography
- "Introduction to System Services" (Apple Developer Connection) provides the most authoritative guide to writing services for Mac OS X. This got me most of the way to a working service.
- "MakingServices" (CocoaDev) has some additional information on building services. It's a bit outdated (some of the things they refer to are deprecated in Mac OS X 10.5), but provides some hints as to the correct build type for the project (see notes below).
- "Test Driving Your Code with OCUnit" (Apple Developer Connection) is a quick intro to writing unit tests for Objective C with Xcode. This is also a bit outdated (see notes below).
- "10.5 commandline NSInvalidArgumentException" (Apple Installer-dev Mailing List) explains a workaround for an odd crash I ran into when building the package for this project.
Things that were not obvious
- My road to the correct project/build type for a stand-alone service (as opposed to an application that does its own thing and provides a subset of its functionality as a service) was a bit convoluted. I started by creating a "Foundation Tool" project from the "Command Line Utility" category of projects under Xcode 3, but wound up needing to create an application build target within the project to get things working. A strict command-line tool doesn't work because it's not a bundle and you can't add an Info.plist file to it; similarly, a "loadable bundle" doesn't quite work since (for reasons that aren't entirely clear to me) the executable inside the bundle doesn't run as expected.
- There appears to be a bug in Xcode where, when editing the Info.plist file to add the requisite service-identifying keys, the editor transposes the "human-readable" version of the plist key with the "raw" version. Specifically, when creating the menu item entry for the service, Xcode (at least 3.1.1) generates the "raw" key as "Menu item title" and the "human-readable" key as "default". These should be switched; this can be done by editing the Info.plist file directly or by switching to raw key/value editing mode and changing the key to "default".
- OCUnit is now built into Xcode. To actually run the unit tests, all you need to do is build the OCUnit target.
- Somehow, the OS was much more interested in the service bundle in my project build directory than in the one I actually installed in /Library/Services. I had to clean my build directory, log out, and log back in to make it find the right one. Even now, I'm not sure it would prefer the one in /Library/Services over the one in my build directory.
