I can't get services to work. I am trying to provide a service, just like in this website:
Mac Dev Center: Services Implementation Guide: Providing a Service
I copied that code to a new Cocoa app (except instead of rot13 I just NSLog the string). I copied the info.plist entry to my info.plist, replacing only "NewsReader" with my app's name "serv." That's it, then I moved my app to /Applications, ran it, quit it, and restarted the computer (core2duo imac, 10.5.8). Nothing is added to the Services menu of any other app, and running the suggested
/Applications/TextEdit.app/Contents/MacOS/TextEdit -NSDebugServices com.yourcompany.serv logs nothing.
Has anyone ever managed to write a service before? What am I doing wrong?
Here's the entirety of my code:
Code:
@implementation serv
- (void) applicationDidFinishLaunching:(NSNotification *)note
{
NSLog(@"launch");
[NSApp setServicesProvider:self];
}
- (void)report:(NSString *)s
{
NSLog(s);
}
- (void)simpleEncrypt:(NSPasteboard *)pboard
userData:(NSString *)userData error:(NSString **)error {
NSLog(@"simpleEncrypt");
NSString *s = [pboard stringForType:NSStringPboardType];
[self report:s];
}
@end
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.serv</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSServices</key>
<array>
<dict>
<key>NSKeyEquivalent</key>
<dict>
<key>default</key>
<string>E</string>
</dict>
<key>NSMenuItem</key>
<dict>
<key>default</key>
<string>Encrypt Text</string>
</dict>
<key>NSMessage</key>
<string>simpleEncrypt</string>
<key>NSPortName</key>
<string>serv</string>
<key>NSSendTypes</key>
<array>
<string>NSPasteboardTypeString</string>
</array>
<key>NSReturnTypes</key>
<array>
<string>NSPasteboardTypeString</string>
</array>
</dict>
</array>
</dict>
</plist>