Question

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?

Was it helpful?

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"

OTHER TIPS

The syntax error: invalid arithmetic... tells you that it's the second line where the error is. So just run the second line alone and echo $buildNumber, then you'll see why the PlistBuddy command didn't work and why it gave you the error "...doesn't Exist, Will Create: Flat ..."

Check if CFBundleVersion is present in your Info.plist.

Your script can't create CFBundleVersion if not present, and it stops working. Just add CFBundleVersion in your Info.plist and your script will update it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top