Peter;

Thanks for the response!
Launched on demand based on the Service specifications in Info.plist - there that's a big conceptual milestone! Thank-you!!
(I wish that was written down somewhere I could find...)
So for a stand-alone service should we -terminate after each call?

Here's how I'm installing the .service:

servicesFolderPath = [[NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"Services"];
        if (![fileManager fileExistsAtPath:servicesFolderPath]) {
                [fileManager createDirectoryAtPath:servicesFolderPath 
attributes:nil];
        }
srcPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"MyService" ofType:@"service"]; destPath = [servicesFolderPath stringByAppendingPathComponent:@"MyService.service"]; if ( ([fileManager fileExistsAtPath:srcPath]) && (![fileManager fileExistsAtPath:destPath]) ) {
                [fileManager copyPath:srcPath toPath:destPath handler:nil];
                NSUpdateDynamicServices();
        }  else {
                if (![fileManager fileExistsAtPath:srcPath]) {
                        _WDIfV NSLog(@"MyService.service - Payload Not 
Located.");
                } else {
                        _WDIfV NSLog(@"MyService.service was already 
installed.");
                }
        }       

Nothing appears in the Service menu on Leopard EVER, even after re- logging in. What I observe is that on Tiger, after installing as above, the next time I launch any application its Service menu DOES include my item...

Here's the Info.plist:
<?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>CFBundleInfoDictionaryVersion</key>
        <string>6.0</string>
        <key>NSPrincipalClass</key>
        <string>NSApplication</string>
        <key>CFBundleIdentifier</key>
        <string>com.mycompany.myService</string>
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>CFBundleVersion</key>
        <string>1.0.0</string>
        <key>LSBackgroundOnly</key>
        <true/>
        <key>CFBundleIconFile</key>
        <string>MyIcony</string>
        <key>CFBundleGetInfoString</key>
<string>Version 1.0, Copyright © 2009 My Company. All rights reserved.</string>
        <key>NSHumanReadableCopyright</key>
        <string>Copyright © 2009, My Company.
All rights reserved.</string>
        <key>LSMinimumSystemVersion</key>
        <string>10.4</string>
        <key>CFBundleExecutable</key>
        <string>MyService</string>
        <key>CFBundleName</key>
        <string>MyService</string>
        <key>NSServices</key>
        <array>
                <dict>
                        <key>NSMessage</key>
                        <string>myServiceMethod</string>
                        <key>NSPortName</key>
                        <string>MyService</string>
                        <key>NSMenuItem</key>
                        <dict>
                                <key>Menu item title</key>
                                <string>MyService</string>
                        </dict>
                        <key>NSSendTypes</key>
                        <array>
                                <string>NSStringPboardType</string>
                                <string>NSRTFPboardType</string>
                        </array>
                </dict>
        </array>
</dict>
</plist>



On Feb 4, 2009, at 2:37 PM, Peter Ammon wrote:

Hi Steve,

What appears in the Services menu is entirely determined by the NSServices portion of your Info.plist. If you post that to the list, we can look for any problems.

Your Service is launched on-demand when the user selects it from the menu. Services may be background only, but do not have to be.

On Tiger and earlier, there is no way to avoid needing to log in and out. On Leopard, you can use the function NSUpdateDynamicServices() to immediately scan for new Services. If you're just testing, a quick way to scan for new Services is to run pbs directly:

   /System/Library/CoreServices/pbs

However, pbs has no supported public interface and this will (has already) change, so don't include any reference to pbs in a script. NSUpdateDynamicServices() is the right way to programmatically refresh Services.

-Peter

On Feb 4, 2009, at 7:03 AM, Steve Cronin wrote:

Well, sheesh - that's embarrassing! There is no 'self' until init - I know that! Ugh.

However, that doesn't change my end result!

I never see anything on the Services menu nor anything from the NSLog statements shown below. (Even when I double-click on the .service file; after whcih I CAN see it in the process list in Activity monitor but still no log messages) Logging out and back in doesn't make my service name appear on the Service menu... This is on a 10.5.6 system using a Release build which has been placed in ~/Library/Services.

SO my basic questions still stand:
What event/conditions launches a .service which resides in ~/ Library/Services?
Should/must .service files be 'Background Only'?
Am I missing something basic in my setup here -
I have only a Info.plist and 1 .h (NSObject) and 2 . m files (main and MyService) and no .xib? Other than the 'wrapper' settings are there other compiler settings required for this setup? I have only 2 steps in my build process: 'Compile Source (2)' and 'Link Binary w/ Lib (1)' [Cocoa]



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to