2

I'm writing a command-line tool that other developers will run. I'd like to extract the bundle id of the app from their Info.plist file. I can read the plist using something like PlistBuddy or Python's plistlib but I don't know how to reliably extract the $PRODUCT_NAME variable. How can I do this from a shell script?

Jasonw
  • 5,054
  • 7
  • 43
  • 48
Tyler
  • 28,498
  • 11
  • 90
  • 106
  • Bundle ID or Product name? You ask both. The Product name isn't stored in the Info.plist. It's stored in the build settings. – James Webster Nov 22 '12 at 15:25

1 Answers1

2

I'd like to extract the bundle id of the app from their Info.plist file

You can get the bundle ID from the plist using PlistBuddy:

/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" Info.plist 

The product name isn't likely to be available as that information is stored in the Build Settings, not the Info plist.

James Webster
  • 31,873
  • 11
  • 70
  • 114
  • Yeah it just prints $(PRODUCT_NAME), are you saying it is impossible to get this value in a terminal shell script? – JeremyF Apr 15 '22 at 15:41
  • Ooof. 10 year old question. I'm afraid I haven't been an active developer for the last few years. I don't know about grabbing details from the build settings via the terminal now sorry. – James Webster Apr 15 '22 at 16:14
  • This is fine, I ended up taking a different approach to manage all our apps and automations. – JeremyF Jul 19 '22 at 19:01