Re: How to create a simple service in Leopard?
Re: How to create a simple service in Leopard?
- Subject: Re: How to create a simple service in Leopard?
- From: Dalmazio Brisinda <email@hidden>
- Date: Sun, 4 Jan 2009 03:18:01 -0600
Hello,
Okay, a bit of weirdness is going on.
For the Info.plist file, It seems that Xcode generates the key for the
menu item as "Menu item title" instead of "default" after a build --
even when it appears as "default" in Xcode. If I manually edit the
Info.plist file and make it "default" everything works fine.
Looks like an Xcode bug to me.
Best,
Dalmazio
On 4-Jan-09, at 2:50 AM, Dalmazio Brisinda wrote:
Hello,
Whoops, actually SimpleService does work... my mistake. I'll have a
closer look at this example.
Best,
Dalmazio
On 4-Jan-09, at 2:41 AM, Dalmazio Brisinda wrote:
Hello,
I'm having some problems writing and then installing my own service
and would be grateful if anyone could help. I've followed the OS X
documentation but still can't seem to get my custom "hello world"
service to work.
I'm creating a new project in Xcode using the Foundation Tool as I
don't need an interface. My main.m looks like this:
#import <Foundation/Foundation.h>
#import "MyService.h"
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
MyService * myService = [[MyService alloc] init];
NSRegisterServicesProvider(myService, @"MyService");
[[NSRunLoop currentRunLoop] run];
[myService release];
[pool drain];
return 0;
}
Then I create the MyService class and just add the method given in
the OS X documentation almost verbatim (http://developer.apple.com/documentation/Cocoa/Conceptual/SysServices/Tasks/providing.html#/
/apple_ref/doc/uid/20000853). I don't need to return anything back
so I just take a string from the pasteboard. All I'm doing here is
printing the pasteboard string to the console using this method
signature:
- (void)doMyService:(NSPasteboard *)pboard userData:(NSString
*)userData error:(NSString **)error;
Now, when I advertise the service, I need to add the NSServices
entry (as given in the link above) to the Info.plist file. However,
there isn't one for a plain foundation tool template -- nor is
there a package wrapper. So, I just add another target (loadable
bundle) and add all the target information to the loadable bundle,
and enter the NSServices entry into the auto-generated ...-
Info.plist file. I make this bundle the active target, change the
wrapper to a .service extension in the configuration options, and
build it successfully. Then I place this service bundle into ~/
Library/Services, log out, and log back in. And voila, my menu item
doesn't even appear in the Services menu.
Any ideas how to get such a simple non-gui service to work?
BTW, I tried to two examples in /Developer/Examples/Appit/
SimpleService & SimpleImageFilter, and I can't get these to work
either.
I'm running Leopard 10.5.6 on Intel.
Best,
Dalmazio
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden