xcodeshellbuild-numbers

Xcode 4.3 Shell Script synthax error on autoincrement script


I have this script made to autoincrement the build number on every build:

#!/bin/bash
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" $INFOPLIST_FILE)
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" $INFOPLIST_FILE

I inserted it on the build phases before the "copy bundle resources". I get an error saying:

Command /bin/sh failed with exit code 1 /Users/ricardodelfingarcia/Library/Developer/Xcode/DerivedData/Flat_Wars-bhkfhubvxegpazcnqcswodoejxeo/Build/Intermediates/Flat Wars.build/Debug-iphoneos/Flat Wars.build/Script-B6B328B815AA6F9900C26C37.sh: line 4: File Doesn't Exist, Will Create: Flat Invalid Arguments + 1.0: syntax error: invalid arithmetic operator (error token is "'t Exist, Will Create: Flat Invalid Arguments + 1.0") Parse Error: Unclosed Quotes Value Required for Set Command

What is the problem?


Solution

  • Problem is you have space in your directory name.

    This will work:

    #!/bin/bash
    buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
    buildNumber=$(($buildNumber + 1))
    /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"