How to Add Xcode Bot Integration Number Into Build Script How to Add Xcode Bot Integration Number Into Build Script xcode xcode

How to Add Xcode Bot Integration Number Into Build Script


I implemented this using a Shell Script Build Phase in my Xcode project. In my case, I used the integration number to set the internal version of my built product. My script looks like this:

if [ "the$XCS_INTEGRATION_NUMBER" == "the" ]; then    echo "Not an integration build…"    xcrun agvtool new-version "10.13"else    echo "Setting integration build number: $XCS_INTEGRATION_NUMBER"    xcrun agvtool new-version "$XCS_INTEGRATION_NUMBER"fi

Note that XCS_INTEGRATION_NUMBER exists by default in the Xcode Server build environment. If you want to simulate an integration build (for the purposes of this script), you can simply add it to your build settings as a custom variable.


You actually don't even need agvtool to set the build number to the Xcode bot integration number. Simply set the Build number to ${XCS_INTEGRATION_NUMBER} in your project settings.


I added (+) a Run Script to my targets Build Phase just prior to Compile Sources step. This one line script works for me to set the integration number as the build number. Thanks Kaelin, I just wanted to simplify things a little bit.

[ -z "$XCS_INTEGRATION_NUMBER" ] && echo "Build #0" || xcrun agvtool new-version ${XCS_INTEGRATION_NUMBER}