Skip to main content
All CollectionsKnowledge BaseiOS
Automate your Bundle Version in Xcode increments with your Build numbering
Automate your Bundle Version in Xcode increments with your Build numbering
Updated over a week ago

All Bitrise builds have a build number. The first build of your app is, by default, number 1, and the build number gets incremented with each build. You can get a build’s Bitrise build number on the website (on the Build Details page), as well as via the $BITRISE_BUILD_NUMBER Environment Variable.

Depending on how you handle your build and bundle versioning, your build might fail with an error stating that the Xcode Project Version is not greater than the current version. This is because it is expected for your bundle version to increment away from the last uploaded version and will result in issues uploading the .ipa file.

Thankfully, we have a script that will get you sorted out! The following allows you to enter your own Project Path and ensure that the bundle version increments each time and is equal to the build number of the build that runs the script. You can add this anywhere before your Archive Step:

cd $BITRISE_SOURCE_DIR
#Insert your project path below
PROJECT=./EXAMPLE_PATH.xcodeproj/project.pbxproj
sed -i '' -e 's/CURRENT_PROJECT_VERSION \= [^\;]*\;/CURRENT_PROJECT_VERSION = '$BITRISE_BUILD_NUMBER';/' $PROJECT
build_number=`sed -n '/CURRENT_PROJECT_VERSION/{s/CURRENT_PROJECT_VERSION = //;s/;//;s/^[[:space:]]*//;p;q;}' $PROJECT`

That is all! You have now automated your bundle versioning process to work off of changes in your build numbering.

Happy Building 🚀

Did this answer your question?