Dani Pralea
Dani Pralea

Reputation: 4551

Incrementing build number Xcode (on last component)

I currently have this as a script to auto-increment the build number in my Xcode project:

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

What this script does is incrementing from let's say 1285 to 1286.

What I want to do is have it on components: Increase it from 1.0.4523 to 1.0.4524

The reason I need this is because Fabric and iTunes Connect's Testflight use different notation systems for detecting a separate version and this way I can combine the two and not edit it manually always when doing a build for one and a build for the other.

Any help would be greatly appreciated! Thanks in advance!

Upvotes: 1

Views: 1509

Answers (2)

Mike Glukhov
Mike Glukhov

Reputation: 1830

Simpler to keep app version and build number separately and use Apple versioning

enter image description here

After add run script link this:

enter image description here This script will update your build number during each build for all targets.

Dont forget to setup Apple versioning: enter image description here

Upvotes: 2

trojanfoe
trojanfoe

Reputation: 122381

Hold the version information outside of the Info.plist file in a separate version file. This file is kept under source control.

You then:

  1. Read the version file to get the major, minor and build numbers.
  2. Increment the build number.
  3. Update the version file to capture the new build number.
  4. Format the version string as major.minor.buildnum and write that to the Info.plist file.

I do something similar in this script, however I use Python, rather than shell script, as it's much more powerful.

Upvotes: 1

Related Questions