Skip to content

Instantly share code, notes, and snippets.

@ming-chu
Last active March 30, 2018 07:16
Show Gist options
  • Save ming-chu/72971cff4398a52f1bf3b2c783b54760 to your computer and use it in GitHub Desktop.
Save ming-chu/72971cff4398a52f1bf3b2c783b54760 to your computer and use it in GitHub Desktop.
Get build number using PlistBuddy
# INFOPLIST_FILE="xxx/Info.plist"
# echo $INFOPLIST_FILE
# get current plist file path=> $ what-marketing-version | grep "Found" | awk '{print $NF}'
# awk '{print $NF}'; will split the sentense and get the last one (NF=number of fields in the current record)
#
#PLIST_PATH=$(agvtool what-marketing-version | grep "Found" | awk '{print $NF}')
#PLIST_PATH="${PLIST_PATH%\"}"
#PLIST_PATH="${PLIST_PATH#\"}"
#(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$PLIST_PATH")
#assign to a variable
#BUILD_NUMBER=$(PLIST_PATH=$(agvtool what-marketing-version | grep "Found" | awk '{print $NF}') && PLIST_PATH="${PLIST_PATH%\"}" && PLIST_PATH="${PLIST_PATH#\"}" &&(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$PLIST_PATH"))
#one line statment:
(PLIST_PATH=$(agvtool what-marketing-version | grep "Found" | awk '{print $NF}') && PLIST_PATH="${PLIST_PATH%\"}" && PLIST_PATH="${PLIST_PATH#\"}" &&(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$PLIST_PATH"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment