简体   繁体   中英

Creating an OS X Service

I'm trying to create an OS X Service. I found Providing System Services in Apple's documentation, however I'm finding it less than clear on what exactly I need to do. I'm currently using an application to register my service (thinking that would be more straight forward - eventually I'd like to create a .service), however even after a logout/login my service still doesn't appear in the list of services in the menu.

Is there some step missing from the linked document that I'm missing? I feel like there is some registration step so that the OS knows about my service (in addition to what is listed in that doc), but I'm not able to find anything.

Thanks in advance. :)

Edit: Here is my NSServices dictionary from my Info.plist file:

    <key>NSServices</key>
<array>
    <dict>
        <key>NSPortName</key>
        <string>POPrlTest</string>
        <key>NSMessage</key>
        <string>shortenUrlService</string>
        <key>NSSendTypes</key>
        <string>NSStringPboardType</string>
        <key>NSReturnTypes</key>
        <string>NSStringPboardType</string>
        <key>NSMenuItem</key>
        <dict>
            <key>default</key>
            <string>Shorten URL</string>
        </dict>
    </dict>
</array>

Make sure your NSServices dictionary has everything it needs. If you're not sure, please post it so we can tell you.

Make sure you are launching your app first to get the system to see the Service. Make sure you are registering the services handler in your app using - setServicesProvider:

Also, check the Console log as that might give you some useful error info.

You might want to look at some commercial products to help you with this. See this posting on Fun Script .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM