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

前端 未结 5 1604
慢半拍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 07:55

    Using PlistBuddy, an app by Apple it is possible to assign the string to var like this:

    #!/bin/sh   
    BUNDLE_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "${BUILD_ROOT}/${INFOPLIST_PATH}")
    

    Where BUILD_ROOT and INFOPLIST_PATH are variables set by Xcode if you run this script in a "Run Script" build phase.

提交回复
热议问题