When compiling a project, this script should increase the build version of the Xcode project by one when the system name matches. Keep in mind that these are just Unix commands in a script (not Applescript, Python or Perl) inside Target-> Build Phases-> Run script in Xcode.
I made "echo $ USER" in the terminal. This prints the username of the registered user just fine, and this is the same line that I put in the conditional statement in the second block of code.
The first block of code works. The second, which the conditional operator adds, does not.
#!/bin/bash buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE") buildNumber=$(($buildNumber + 1)) /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
#!/bin/bash username=$USER if [ username == "erik" ]; then buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE") buildNumber=$(($buildNumber + 1)) /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE" fi
Syntax:
$ USER parsing (case sensitive)
The semicolon immediately after closing the brackets in the if statement
Then the operator on the same line as the operator
Glimpse
source share