I'm on MacOS Mountain Lion: is there anything like a template to write a service for ML? I use Xcode 4.4.1
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.
Related
My macOS app can launch a faceless helper application which is shipped in its Contents/Library/LoginItems using Apple's Service Management Framework, as described in Apple documentation. Funny thing is, when I request the unix ps program to give me the command/paths, for this helper process, it gives the bundle identifier instead. Example:
jk$ ps -x -o command
...
com.mycompany.MyAgent
...
It gives me the same answer with or without the -c option on ps.
Because my app comes in several flavors and versions which each contain different helpers, and because users may have multiple installations, and because of the sometimes strange behavior of Launch Services, for self-testing and diagnostic purposes, I would like to get the path to the running helper's package or executable.
Why does ps give the bundle identifier instead? How can I get the path?
A program can a) rewrite the memory pointed to by argv and the strings it points to, and/or b) call setprogname().
I seem to recall that setprogname() does not affect the output of ps, but rewriting argv does. I could have that backwards, though. I know that Wine does both and affects the command that ps sees.
Title. Near identical code for both projects in their respective templates. Both projects successfully creates a PubNub object (the logger shows up in the command line), however only one of them (iOS Single View App) receives a response through func client(client: PubNub!, idReceiveMessage message: PNMessageResult!). Why does the project in the Command Line template not work?
Asynchronous operations don't work automatically for command line tools. They will work by default for a Mac OS X app or an iOS app.
Have you seen the advice in this post about manually entering the run loop?
Keep command line tool alive
Just for clarification. Command line applications are very different than IOS apps. IOS/Mac OSX provides a different runtime environment that abstracts away the complexity of writing your own runloop to manage things such as asynchronous calls. The PubNub IOS SDK is built for those environments, not for command line applications.
If you want to build a command line app using PubNub I'd strongly recommend using a different SDK (maybe node or ruby, mono c-sharp) that would require far less infrastructure work on your part.
http://www.pubnub.com/developers
I wrote an "emacsinit" file like
/usr/local/Cellar/emacs/24.1/Emacs.app/Contents/MacOS/Emacs --daemon
and drag the file "emacsinit" into the "Login Items".
But it doesn't seem to work. The server doesn't start after system start.
How can I deal with it?
The Login Items scheme likely expects that the launched apps are full app bundles, not just individual shell scripts.
A tool called Platypus can be used to wrap your shell script up as a full application.
Another option is to create an OS X per-user launchd item for Emacs, which is easy if you use an app called Lingon. (Older Lingon versions were free, and will also do the trick.)
For what it's worth, I get all the same advantages with less work by starting the regular Emacs app and then activating the server with the following code:
(require 'server)
(unless (server-running-p)
(server-start))
After that, I can create new text and graphical frames freely using emacsclient.
I'm am getting ready to attempt to implement Scripting Bridge for the first time, specifically to allow my program to construct and send emails to individual (or all) members of an opt-in email database.
Unfortunately, I'm already stuck on the first step... creating the Mail.h file.
According to Apple's documentation:
To create a header file, you need to run two command-line tools—sdef and sdp—together, with the output from one piped to the other. This is the recommended syntax:
sdef /path/to/application.app | sdp -fh --basename applicationName
However, when I attempt to execute this, I receive the following errors:
-bash: sdef: command not found
-bash: sdp: command not found
My guess is that I'm trying to execute programs that are (clearly) not installed on my system, which is a MacBook Pro running Lion (10.7.4)
A quick google search turned up an older version of sdef for v10.4, but I'm now wondering: Is this process still the recommended procedure, or is there another way I should be generating a Mail.h header file? Apple's documentation is rather vague on this point.
Any help would be appreciated.
After some additional research and experimentation, I was able to get everything working by allowing XCODE to create the header files, rather than doing it manually from the command line.
XCODE also uses the sdp and sdef commands, but had no problem accessing them. I am still not entirely certain why I could not run the commands in the bash shell, but I suspect they must be run from the root user perhaps?
In any event, here is a link to the Apple Documentation which outlines the steps I took to get everything working correctly:
https://developer.apple.com/library/mac/#samplecode/SBSystemPrefs/Listings/ReadMe_txt.html
You should be able to use sdef and sdp after installing the command line tools. These are an optional install since XCode 4.3.
http://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/WhatsNewXcode/Articles/xcode_4_3.html#//apple_ref/doc/uid/1006-SW2
I am trying to add a vlc:// helper protocol on Mac OS X. To register the protocol, I have unsuccessfully been playing around with the MoreInternet PrefPane.
What I want to have in my browser is a vlc://someressource.com/audio.mp3, which should launch VLC and add http://someressource.com/audio.mp3 to the playlist (this works fine on Windows and also Linux if I remember correctly). Maybe even just have vlc://http:// so that https would also be supported.
I have no idea how to achieve this. I tried making a bash script, which MoreInternet would not accept. Then I tried making an application through Automator with my Bash script embedded. That did not work either, as the Automator application has no "creator code" - whatever that is?!
Can any of you guys point me in the right direction?
Thanks in advance!
It looks like MoreInternet hasn't been updated since 2006, so I wouldn't count on it working well.
A creator code is a unique 4-character code assigned to applications, before bundle IDs were invented. If you want one, register a code and then put it in your Info.plist under the CFBundleSignature key.
Rather than using MoreInternet, it may suffice to declare your app as a URL handler in your Info.plist, under CFBundleURLTypes. Ideally, VLC.app would do that.