Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Add Xcode Bot Integration Number Into Build Script

I'm creating an iPad application with a Settings.bundle file. I'm writing build scripts to display the application version number and the xcode bot integration number (not the bundle build number). I've searched the web and couldn't find any solution. Here's what I got yet:

-- Add the app version number
cd $PROJECT_DIR
cd "$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.app"

RELEASE_VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" Info.plist)
/usr/libexec/PlistBuddy -c "Set :PreferenceSpecifiers:1:DefaultValue $RELEASE_VERSION" Settings.bundle/Root.plist

-- Add the build version number
BUILD_NUMBER=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" Info.plist)
/usr/libexec/PlistBuddy -c "Set :PreferenceSpecifiers:2:DefaultValue $BUILD_NUMBER" Settings.bundle/Root.plist

In the build version number, I would like to replace the CFBundleVersion with the xcode bot Integration number.

like image 404
iDev Avatar asked Apr 10 '14 12:04

iDev


People also ask

What is Xcode bot?

Bots are processes that Xcode Server runs to perform integrations on the current version of a project in a source code repository. An integration is a single run of a bot. Integrations consist of building, analyzing, testing, and archiving the apps (or other software products) defined in your Xcode projects.

What is integration app in Xcode?

In Xcode on your development Mac, you set up bots that run on the server. These bots process your apps, using the source code in your repository, and report back the results. Each run of a bot is called an integration, and these runs occur regularly throughout the development life cycle of your app.

What is Xcode server builder?

Xcode Server is a continuous integration platform developed by Apple for analysing, building and testing and archiving the iOS and macOS apps. One of the painful part in the iOS development is Certificates and Provisioning profiles.


2 Answers

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.

like image 107
Kaelin Colclasure Avatar answered Sep 22 '22 23:09

Kaelin Colclasure


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.

like image 45
Christopher T Avatar answered Sep 24 '22 23:09

Christopher T