Created
May 9, 2014 14:34
-
-
Save kitschpatrol/efa8f87f3c78b3d433ca to your computer and use it in GitHub Desktop.
xcode-build-number-generator.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Automatically updates the App's build number | |
| # This script should be executed by Xcode before every build | |
| # It should mutate only the built version of the app to keep merges clean. | |
| # (E.g. the Xcode project file just has a <scripted> placeholder string for the build number.) | |
| # Pulls the major version FROM the Plist File (set in Xcode) | |
| # Puts the generated build number INTO the Plist File (overwriting whatever was set in Xcode) | |
| # Use LP specified format App_vX_YYMMDD.HHMM | |
| # Build scripting strategy is described here: | |
| # http://stackoverflow.com/a/18701920/2437832 | |
| # For testing | |
| #SOURCE_ROOT="/Users/mika/Code/NYSCI/lp-nysci.scigames" | |
| #TARGET_BUILD_DIR="/Users/mika/Code/NYSCI/lp-nysci.scigames/DerivedData/SciGames/Build/Products/Debug-iphonesimulator" | |
| #CONTENTS_FOLDER_PATH="SciGames.app" | |
| BUILD_NUMBER_FILE="${SOURCE_ROOT}/BuildNumber" | |
| PLIST_FILE="${TARGET_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/Info.plist" | |
| majorVersion=`/usr/libexec/PlistBuddy -c "PRINT:CFBundleShortVersionString" "$PLIST_FILE"` | |
| dateTime=`date "+%y%m%d.%H%M"` | |
| buildNumber=App\_v$majorVersion\_$dateTime | |
| # Store build number | |
| echo $buildNumber > $BUILD_NUMBER_FILE | |
| echo Writing generated build number \"$buildNumber\" to \"$PLIST_FILE\" | |
| /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$PLIST_FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment