1

I'm using Xcode 4.3 and I have followed this user's steps to create the script:

Version vs build in XCode

For whatever reason it does not look like I can leave a comment there. As the answer area in StackOverlow is not a forum/discussion I'm a bit forced to ask a question based off that answer.

In Step 7 he cites 2 ways to increment Build Version: Number and Hex Number

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

and

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

Both are returning the exact same shell error:

syntax error: invalid arithmetic operator (error token is ".0")
command /bin/sh failed with exit code 1

I went the summary tab and both version and build were 1.0. If I change this to just "1" the error is "line 4 1 + 1: syntax error: invalid arithmetic operator (error token is " + 1")

What am I doing wrong and what can I do to fix this?

1 Answer 1

5

Your build number has a floating point value, so change your code to

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

as suggested in this SO post.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.