How to detect Info.plist location for any given .app program from Terminal?

What is the reliable way to locate the file Info.plist for any given .app program? Likely most apps have it in MyApp.app/Contents/Info.plist, however other third party apps store it on another subfolder location, or even have several of them in different subfolders.

Is there any parameter which can do this which never fails, like defaults read MyApp.app Info.plist? (this is an example, does not work).

There must be one, because when I launch the application.app from Finder it always launches, so MacOS must know where Info.plist is located and how to read it.

I would like to retrieve such information from Terminal, however.

Answered by DTS Engineer in 741592022

I'm planning in reading where the main binary is for the application … so I can launch the app from Terminal

Most folks run apps from Terminal using the open command line tool. Does that work for you?

See the open man page for more details.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I just look through a dozen or so 3rd-party apps, and they all contained Contents/Info.plist. Can you give any examples where it's not there? (As for "several in different subfolders", an app may contain bundles or frameworks, each of which contains its own Info.plist.)

The folder "3DMark Wild Life Extreme.app" contains the subfolders "WrappedBundle" and "Wrapper" inside, no Contents folder.

The folder "3DMark Wild Life Extreme.app" contains the subfolders "WrappedBundle" and "Wrapper" inside, no Contents folder.

That is an iOS app running on Apple silicon.

I would like to retrieve such information from Terminal

To what end?

It’s generally best to treat an app like an opaque blob, and access its internal structures using high-level APIs like NSWorkspace. However, doing that from Terminal can be tricky. If you can explain more about your high-level goal, we should be able to put you on the right path.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I'm planning in reading where the main binary is for the application:

% defaults read '/Applications/3DMark Wild Life Extreme.app/Wrapper/AttanExtreme.app/Info.plist' CFBundleExecutable
AttanExtreme

so I can launch the app from Terminal:

% /Applications/3DMark\ Wild\ Life\ Extreme.app/Wrapper/AttanExtreme.app/AttanExtreme
Killed: 9

How it's supposed to be done?

The find command can do this:

% find '/Applications/3DMark Wild Life Extreme.app' -name 'Info.plist' -print

will output the full path for each Info.plist file inside the application, like:

/Applications/3DMark Wild Life Extreme.app/Wrapper/AttanExtreme.app/Info.plist

If you're sure there is only one such file, you can use the defaults read on it:

% defaults read "$(find '/Applications/3DMark Wild Life Extreme.app' -name 'Info.plist' -print)" CFBundleExecutable

but, if there are several such files, you'd better loop on them:

% while read file; do echo "$file"; defaults read "$file" CFBundleExecutable; done < <(find '/Applications/3DMark Wild Life Extreme.app' -name 'Info.plist' -print)

If you want to do this for every application in the /Application folder (or in the /System/Applications folder), you can even do:

% while read file; do echo "$file"; defaults read "$file" CFBundleExecutable; done < <(find '/Applications' -name 'Info.plist' -print)

Is it what you are looking for ?

Accepted Answer

I'm planning in reading where the main binary is for the application … so I can launch the app from Terminal

Most folks run apps from Terminal using the open command line tool. Does that work for you?

See the open man page for more details.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Yes it works, thank you!

How to detect Info.plist location for any given .app program from Terminal?
 
 
Q