The mechanism behind `open foo.app` on Mac OS X

May 29th, 2014 | Categories: Apple, Mac OS X | Tags:

If you type

open foo.app

in a Mac terminal window, or alternatively, click on foo.app in Finder the application foo will be launched.

It turns out that foo.app is actually a directory which made me wonder ‘What determines what gets launched?’

If you look inside an .app folder, you will find a Contents folder. Inside this will be, among other things, a file called Info.plist.  It is this file that determines what gets launched. For example, there is an entry in this file called CFBundleExecutable that determines the executable to be launched.

Full details at https://developer.apple.com/library/mac/documentation/Carbon/Conceptual/LaunchServicesConcepts/LSCConcepts/LSCConcepts.html#//apple_ref/doc/uid/TP30000999-CH202-TP9

Thanks to Chris Beaumont for the link above.

  1. Ian Cottam
    May 29th, 2014 at 18:39
    Reply | Quote | #1

    Yes, when I told you about attributes and resource forks, I was thinking of ordinary files.
    The behaviour described runs the app, but that is what you would expect I guess.

    With ordinary files, it does mean you can call something fred.txt but set some nasty program to open it. Hence, by default – especially if you download a file – OS X warns you to be very careful.