Auto increase build number in XCode

Apple demand the build number on each app version must be higher than previous one. I found this script to auto increase build number based on git log history entry number, and have been using it for quite a long time, very handy.

1
2
3
4
5
6
7
8
9
#Update build number with number of git commits if in release mode
if[ ${CONFIGURATION} == "Release"] || [ ${CONFIGURATION} == "AdHoc"]; then
buildNumber=$(git rev-list HEAD | wc -l | tr -d ' ')
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber""${PROJECT_DIR}/${INFOPLIST_FILE}"
fi;

the only ting to remember is always do a push before build.

There is another way to increase build number by creating a local cfg file to save this number and increase by perl script. Found on hockeyapp.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s