Skip to content

Instantly share code, notes, and snippets.

@sysradium
Last active February 10, 2017 12:35
Show Gist options
  • Save sysradium/5aa1ef46d9873fc27514153add787e44 to your computer and use it in GitHub Desktop.
Save sysradium/5aa1ef46d9873fc27514153add787e44 to your computer and use it in GitHub Desktop.
XCode project versioning
#!/bin/bash
GITBRANCH=$(git branch | grep "\*" | awk '{print $2}')
PREFIX="XC"
if [ -z "${PROJECT_DIR}" ]; then
PROJECT_DIR=$(pwd)
fi
GIT_BRANCH=$(git branch | grep "\*" | awk '{print $2}')
BUILD_NUMBER=$(xcrun git rev-list ${GIT_BRANCH} | wc -l | tr -d ' ')
BUILD_HASH=$(xcrun git rev-parse --short --verify master | tr -d ' ')
echo "#define ${PREFIX}BUILD_NUMBER ${BUILD_NUMBER}" > "${PROJECT_DIR}/Version.h"
echo "#define ${PREFIX}BUILD_HASH @\"${BUILD_HASH}\"" >> "${PROJECT_DIR}/Version.h"
find "${PROJECT_DIR}" -iname "*.plist" -maxdepth 1 -exec touch {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment