How to read plist information (bundle id) from a shell script

前端 未结 5 1595
慢半拍i
慢半拍i 2020-12-14 07:29

I\'d like to write a script that can read info like Bundle Identifier or maybe version number from the Info.plist of the app. Xcode doesn\'t seem to give that information in

5条回答
  •  暖寄归人
    2020-12-14 08:03

    The defaults command can read/write to any plist file, just give it a path minus the .plist extension:

    $ defaults read /Applications/Preview.app/Contents/Info CFBundleIdentifier
    
    com.apple.Preview
    

    This pulls the CFBundleIdentifier value directly from the application bundle's Info.plist file.

    Defaults also works with binary plists without any extra steps.

提交回复
热议问题