1

I have followed all the Apple documentation for setting up a service for a right click menu list and for the services list:

  1. I have made all the relevant info.plist entries. (send types, port name, menu title, instance method, etc.)
  2. I have created the method which handles services.
  3. I have added service registration code in the app.
  4. I built my app, put it in the application directory, logged out and back in.

Despite all this I cannot see my service in any menu item.

EDIT** Here is the services part of my info.plist:

    <key>NSServices</key>
<array>
    <dict>
        <key>NSMenuItem</key>
        <dict>
            <key>default</key>
            <string>MyApp/Send to MyApp</string>
        </dict>
        <key>NSMessage</key>
        <string>contentService</string>
        <key>NSPortName</key>
        <string>MyApp</string>
        <key>NSSendTypes</key>
        <array>
            <string>NSStringPboardType</string>
            <string>NSFileContentsPboardType</string>
        </array>
    </dict>
</array>

What am I doing wrong? thanks in advance.

Zigglzworth
  • 6,645
  • 9
  • 68
  • 107
  • Could you edit your question and paste the relevant Info.plist entries? Also, using `-NSDebugServices` and `pbs -dump_pboard` can help you diagnose the issue. –  Oct 01 '11 at 18:32
  • Have you checked if your service is enabled in the system's keyboard preferences? I think services of third-party apps are disabled by default. – omz Oct 01 '11 at 18:55
  • My service isn't even in the keyboard services list. @Bavarious : I have attached the services section of the info.plist to my question. – Zigglzworth Oct 01 '11 at 19:03
  • Can you check the output of `/System/Library/CoreServices/pbs -dump_pboard`? See if your application is listed there. Try `/System/Library/CoreServices/pbs -debug` as well. –  Oct 01 '11 at 19:07
  • Another thing you can try is `/Applications/TextEdit.app/Contents/MacOS/TextEdit -NSDebugServices com.yourcompany.yourapp` (using your application bundle identifier) in Terminal.app and then open the Services menu. You should see some debugging information in Terminal.app. –  Oct 01 '11 at 19:09
  • Ok the problem seems to be fixed. I just cleaned my build folder in Xcode and rebuit. logged in and out and than went to system's keyboard preferences to enable the service. But how do I make the service enabled by default? – Zigglzworth Oct 01 '11 at 19:17
  • How do you enable/disable & show/hide context menu item in above way? Or if there is any alternate way too? – vkg Jan 30 '20 at 13:43

1 Answers1

6

I have followed all the Apple documentation for setting up a service…

Ah, that's the problem: You stopped there. You also need to add the NSRequiredContext key to your service to get it to be enabled by default on Snow Leopard and later.

Fortunately, while the Services documentation doesn't mention that NSRequiredContext is required, the Information Property List Key Reference does explain the value you must provide for it.

Community
  • 1
  • 1
Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
  • My service was available before but this sets it on by default so the user does not need to go to the services preferences and set it. However for some funny reason, sometimes my whole services menu disappears... I'm not sure if my app is doing that or its a system thing. – Zigglzworth Oct 01 '11 at 19:43