3

I'm on MacOS Mountain Lion: is there anything like a template to write a service for ML? I use Xcode 4.4.1

jscs
  • 63,694
  • 13
  • 151
  • 195
user732274
  • 1,069
  • 1
  • 12
  • 28

1 Answers1

3

The service, in generic terms is a unix daemon, that is, a binary file, executed in background.

You can use Xcode's "command line" utility template to make such a daemon; you still need some means of staring it. In most of the cases, you'll stick to launchd. Check the man page on launchd.plist(5) for more info.

Ok, on the "other" services thing. That are part of NSService, see the docs on Info.plist. You will need to make a "generic" Cocoa application, and then expose its services.

There is also a generic document on services here.

Farcaller
  • 3,070
  • 1
  • 27
  • 42
  • 1
    I'm talking about services shown in System Preferences under the keyboard shortcuts section – user732274 Aug 20 '12 at 15:52
  • You can look into any application that supports services, e.g. open up `/Applications/Utilities/Terminal.app/Contents/Info.plist` and check the NSServices key. The last link includes description of keys and code snippets required to implement a service. – Farcaller Aug 20 '12 at 16:19
  • I don't think it's all about inserting a key in a plist: there is also a source code since we're talking about a Mac app... that's why I asked if there were anything like a template – user732274 Aug 20 '12 at 16:23
  • 1
    https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/SysServices/Articles/providing.html#//apple_ref/doc/uid/20000853-BABDICBI contains a code example for one service. – Farcaller Aug 20 '12 at 16:28
  • I've already read that documentation, but something is going wrong: my service is correctly listed in the system preferences but it never shows up in the "Services" menu in any app. Thank you anyway – user732274 Aug 20 '12 at 16:41
  • Check this question: http://stackoverflow.com/questions/3859747/how-do-i-automatically-activate-an-item-in-the-os-x-services-menu – Farcaller Aug 20 '12 at 16:48
  • I found the problem: I did insert the wrong input type. My fault. – user732274 Aug 20 '12 at 16:56