Search code examples
objective-cmacoscocoaapplescript-objc

Different ways to Launch MAC OSX objective C opplication from command line


I have a MAC OSX objective C application say first.app ,in which i use NSAppleScript with admin privileges to run a shell script.This script is indented to launch another Objective C application say second.app.

When you use open command Ex: "open second.app" in shell script it works fine .

But if you launch the second.app by calling its binary Ex: "/second.app/Contents/MacOS/second " in shell script ,then the control don't come back to first.app until second.app closes . when we close the second.app then first.app resumes .

What is the difference in launching the application from open command and calling the applications binary directly as mentioned ?


Solution

  • Calling

    open Second.app
    

    is the same as double-clicking the app's icon in the Finder. The application is started via LaunchServices, and the open command returns immediately.

    Calling

    /path/to/Second.app/Contents/MacOS/Second
    

    starts the application directly (without LaunchServices), and returns only when the application has terminated.