Last active
February 26, 2016 10:29
-
-
Save tommeier/f7f622b1c0a64c7550f0 to your computer and use it in GitHub Desktop.
Updated build versioning script for http://www.raywenderlich.com/105641/change-app-icon-build-time
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
IFS=$'\n' | |
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}") | |
versionNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${PROJECT_DIR}/${INFOPLIST_FILE}") | |
PATH=${PATH}:/usr/local/bin | |
function checkFileExists () { | |
if [[ ! -e "$1" ]]; then | |
echo "Required file unable to be found: $1" | |
exit 1 | |
fi | |
} | |
function generateIcon () { | |
BASE_IMAGE_NAME=$1 | |
IDENTIFY_BIN=$(which identify) | |
if [[ "$IDENTIFY_BIN" == '' ]]; then | |
echo "No 'identify' command found. Please ensure image magick is installed correctly" | |
else | |
BUILD_RESOURCES_DIR="${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" | |
TARGET_PATH="${BUILD_RESOURCES_DIR}/${BASE_IMAGE_NAME}" | |
BASE_IMAGE_PATH=$(find ${BUILD_RESOURCES_DIR} -name ${BASE_IMAGE_NAME}) | |
checkFileExists "betaRibbon.png" | |
checkFileExists "debugRibbon.png" | |
checkFileExists "$BASE_IMAGE_PATH" | |
WIDTH=$(identify -format %w $BASE_IMAGE_PATH) | |
echo "Image width: $WIDTH" | |
FONT_SIZE=$(echo "$WIDTH * .15" | bc -l) | |
echo "Font size: $FONT_SIZE" | |
BADGE_TEXT="$buildNumber" | |
echo "Creating badged icon for: '$BASE_IMAGE_NAME' with '$BADGE_TEXT'" | |
if [ "${CONFIGURATION}" == "Debug" ]; then | |
convert debugRibbon.png -resize ${WIDTH}x${WIDTH} resizedRibbon.png | |
convert ${BASE_IMAGE_PATH} -fill black -font Times-Bold -pointsize ${FONT_SIZE} -gravity south -annotate 0 "$BADGE_TEXT" - | composite resizedRibbon.png - ${TARGET_PATH} | |
fi | |
if [ "${CONFIGURATION}" == "Beta" ]; then | |
convert betaRibbon.png -resize ${WIDTH}x${WIDTH} resizedRibbon.png | |
convert ${BASE_IMAGE_PATH} -fill black -font Times-Boldr -pointsize ${FONT_SIZE} -gravity south -annotate 0 "$BADGE_TEXT" - | composite resizedRibbon.png - ${TARGET_PATH} | |
fi | |
fi | |
} | |
generateIcon "[email protected]" | |
generateIcon "[email protected]" | |
generateIcon "AppIcon76x76~ipad.png" | |
generateIcon "AppIcon76x76@2x~ipad.png" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was trying to add Version number on Splash screen, but not able to success. Can you help me out on that?