NSS is down

I tried to get NSServices working for my application, recently without success. I installed it in accordance with the documentation, but it does not appear in the services menu (however, it appears in the shortcut section in System Preferences as a service menu item) In any case, I installed the service in my application controller as follows:

[NSApp setServicesProvider:self]; 

Public method:

 - (void) addDownloadService:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error 

Then My Info.plist looks like this:

 <key>NSServices</key> <array> <dict> <key>NSReturnTypes</key> <array> <string></string> </array> <key>NSKeyEquivalent</key> <dict> <key>English</key> <string>S</string> <key>Key equivalent (with command and shift)</key> <string>S</string> </dict> <key>NSSendTypes</key> <array> <string>NSStringPboardType</string> <string>NSURLPboardType</string> <string>NSRTFPboardType</string> </array> <key>NSPortName</key> <string>MyApp</string> <key>NSMessage</key> <string>addDownloadService</string> <key>NSMenuItem</key> <dict> <key>English</key> <string>MyNewService</string> <key>default</key> <string> MyNewService </string> </dict> </dict> </array> 

I tried running the debug command with textedit as follows: /Applications/TextEdit.app/Contents/MacOS/TextEdit -NSDebugServices com.companyname.MyApp

which displays the following: MyNewService (com.companyname.MyApp) is disabled in the services menu and disabled in the context menu according to the standard services policy.

Any ideas why this might not work?

Thanks Colin

+7
cocoa macos
source share
3 answers

I just went through the same problem. It seems that Snow Leopard disables third-party services by default.

You need to go to Settings> Keyboard. Select the second tab (something is fast, I donโ€™t remember right now), select "Services", find your own and activate it.

There is no other workaround that I know of.

+8
source share

You need to specify a list of required contexts using NSRequiredContext. It may be empty.

See http://lists.apple.com/archives/Cocoa-dev/2009/Sep/msg00201.html

+8
source share

The fact that it is displayed in the system settings is good. You are almost there. Assuming that you have already enabled it in the system settings (itโ€™s good to check really quickly, just make sure there is a check nearby), the problem is most likely related to the types of sending and / or returning.

OSX uses send and return types as hints to determine when / where to display the service. For example, if you specified a return type (as you are here), and the control from which you activate the service does not know what to do with the return type, then your service will not be displayed.

The Services Deployment Guide gave me some good troubleshooting steps on how to find out why my services did not appear when I had the same problem (see: https://developer.apple.com/library/mac/# documentation / Cocoa / Conceptual / SysServices / Articles / properties.html )

If your Service is recognized by pbs but does not appear in the Services menu, you can use the default NSDebugServices user to help determine why. For example, to determine why Mails appear or do not appear in TextEdit, you can start TextEdit with NSDebugServices and pass it the package ID of the Mail:

/Applications/TextEdit.app/Contents/MacOS/TextEdit -NSDebugServices com.apple.mail

When I did this, I had a nice error message for my own application:

MyExampleService (com.blah.example) is disqualified because its sending and / or return types cannot be processed by the requestor <NSTextView: 0x7fb681c0e8a0>

I found that my service will appear if I do not specify and return the type, and the error message clearly shows that the return type was a problem in my case. I think this is probably the problem in your case as well, since you specified the return type without specifying anything inside it.

Either remove the return type if you do not expect anything, or if you want to return the text (for example, you want your service to replace the text inside the NSTextView), I would specify the return type as NSStringPboardType as follows:

  <key>NSReturnTypes</key> <array> <string>NSStringPboardType</string> </array> 

There may be something wrong with the send types, although I donโ€™t think there are. You can be sure that if you use debugging steps, I suggested you find out why the service is not displayed.

+4
source share

All Articles