Package command line tool with Cocoa app? - objective-c

Disclaimer: Cocoa newbie here.
I wrote an app with a Cocoa GUI that acts as a wrapper for a command line tool. The problem is the tool does not come standard with OS X. Thus, you have to install the command line tool first before using the Cocoa app, or else the app won't function.
Can anyone point me to some documentation (hopefully, with examples), that can teach me how to install the command line tool when the user installs the app?
Thank you!

Why not include your command line tool inside the bundle of your Cocoa app? This way your Cocoa app is completely self-contained and the issue of "installing" the command line tool does not even arise.

Related

Add support command line

I developed a GUI application for macOS to record video from a computer screen. Can I add support command line? Example,
$myapp -start // Start recording video
$myapp -stop // Stop recording video
and etc.
If it's possible, then how can I implemented it?
It would probably make more sense to create a dedicated command-line tool, built by its own target, and include that as a "helper" executable in your application bundle.
You can then have your application install that as a command-line tool in /usr/local/bin/ by copying it, creating a hard link, etc. If it's a completed tool consider also installing a man page for it.

Is there a Command Line alternative to Xcode & Interface Builder

I'm using XCode to develop an App for Mac OS X. Xcode is heavy on my Mac Resources and it makes the machine pretty sluggish when i work on it for some long time(more than 8 hours). I used to work in C++ with the Command Line & Makefile and it was pretty enough and good for me. Is it Possible that i can Develop apps for Mac, which has some UI(NSStatusItem) fully through Command Line or mostly command Line ?
I explored through some Makefiles for Objective C, but i don't know how to bind the UI actions to the Code. I doubt if it's really possible though Command Line.
I have tried Searching for Command Line alternative for Xcode, but there seems to be None. The Only Choice is Xcode for developing Mac Apps.
I found out this. Maybe it'll help you :)
http://atastypixel.com/blog/objective-c-cocoa-on-the-command-line/

Apple Script on iPhone

I have one Apple script and its working fine on Mac. I want to use it into iPhone application. How can I integrate to iPhone application?
Also AppleScript uses Carbon and Carbon AppleEvents, so trying to get this on a iPhone is pretty much impossible you would pretty much have to write your own AppleScript interpreter, I also would not see much point in having AppleScripts on an iPhone since the main purpose of AppleScript is to control other applications by sending the AppleEvents. Have you thought about using JavaScripts I was looking at that for a web scraping application, using Javascript meant I could update the web scraping code quickly without having to resubmit my app to Apple.
Unfortunately, you can't easily do that. This excerpt is from the latest iOS Developer Program License Agreement:
3.3.2 ... Interpreted code may only be used in an Application if all scripts, code and interpreters are packaged in the Application and not downloaded. The only exception to the foregoing is scripts and code downloaded and run by Apple's built-in WebKit framework, provided that such scripts and code do not change the primary purpose of the Application by providing features or functionality that are inconsistent with the intended and advertised purpose of the Application as submitted to the App Store.
So, in theory it is allowed, nut since AppleScript is not supported by iOS SDK, you should also package an AppleScript interpreter with your app.

Turning a command line app into a Cocoa GUI app on Mac OS X?

Is there any tutorials or references, if such thing is possible, to make GUI applications out of command line apps?
What I mean is, having a command line app, wrap it into an app bundle and create a Cocoa GUI app that would have a simple interface to execute the command line app with its flags and parameters.
As a matter of fact there are. Here is the first hit for a Google search:
Cocoa Dev Central: Wrapping UNIX Commands
What you're looking for is the NSTask class. Check out the documentation for all the information you need.
For very simple scripts, I recommend Platypus. For more complicated scenarios, you could try something like Pashua.

LSOpenURLSpec error

I have created a minimal OS X boot stick (basically the Snow Leopard DVD with all the packages and installer stripped out). I've written a basic Cocoa app launcher to launch other apps that I put in the Applications folder (the minimal install lacks Dock and Finder).
When I try to launch an app I get this error:
LSOpenFromURLSpec() returned -10810 for application (null) path /Applications/MyApp.app
Where "MyApp.app" is the app I tried to launch. I've tried this with both NSWorkspace's openFile method and the UNIX "open" utility and I get more or less the same error. One way that launching an app works is if I just execute the main executable of the app itself. (e.g. /Applications/MyApp.app/Contents/MacOS/MyApp). However this method is kind of inconvenient as it stalls the launcher until the app I launched exits. Any alternate ways to launch an app (or fix the LSOpenFromURL error)?
Thanks
Found a workaround:
/Applications/MyApp.app/Contents/MacOS/MyApp >/dev/null 2>/dev/null &
Using that command starts apps without stalling the launcher.
open relies on Launch Services, which relies on the Finder. Your script workaround starts a new background process executing the application's code with its standard out and standard error open to /dev/null. That should work fine.
The C equivalent under Mac OS X would be to either posix_spawn or fork/vfork then exec the executable file.