Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# This script automatically sets the version and short version string of
# an Xcode project from the Git repository containing the project.
#
# To use this script in Xcode, add the script's path to a "Run Script" build
# phase for your application target.
set -o errexit
set -o nounset
@oxpayken
oxpayken / Versions.markdown
Last active August 29, 2015 14:28
How to adjust the bundle version number in Xcode automatically.

Configure repository

  1. Open an Xcode project in Terminal.
  2. Run git tag -a <version number> -m '<commit message>' i.e. git tag -a 0.1 -m 'The very first version.'.
  3. Optionally, run git push origin --tags to sync all tags with remote.

Configure Xcode

  1. Navigate to Project ➭ TARGETS ➭ Target ➭ Build Phases.
  2. Choose Add Build Phase ➭ Add Run Script
@oxpayken
oxpayken / nth-commit.sh
Last active August 29, 2015 14:27 — forked from airdrummingfool/nth-commit.sh
Checkout the nth commit on a specified branch.
#!/bin/bash
# nth-commit.sh
# Usage: `nth-commit.sh n [branch]`
branch=${2:-'master'}
SHA1=$(git rev-list $branch | tail -n $1 | head -n 1)
git checkout $SHA1
@oxpayken
oxpayken / xcode-build-bump.sh
Last active August 29, 2015 14:27 — forked from sekati/xcode-build-bump.sh
Xcode Auto-increment Build & Version Numbers
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)