Created
April 13, 2018 07:35
-
-
Save jnutting/d189293ac3acbec802e2236232fd4722 to your computer and use it in GitHub Desktop.
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/sh | |
# | |
# A post-build script for running in Xcode, to overlay app icons with some build info. | |
# Requires ImageMagick to be installed before use. | |
commit=`git rev-parse --short HEAD` | |
branch=`git rev-parse --abbrev-ref HEAD` | |
version=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${INFOPLIST_FILE}"` | |
function processIcon() { | |
export PATH=$PATH:/usr/local/bin | |
base_file=$1 | |
base_path=`find "${SRCROOT}" -name $base_file` | |
echo "Processing $base_path" | |
if [[ ! -f ${base_path} || -z ${base_path} ]]; then | |
return; | |
fi | |
target_file=$base_file | |
target_path="${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/${target_file}" | |
if [ $CONFIGURATION = "Release" ]; then | |
cp "${base_path}" "$target_path" | |
return | |
fi | |
width=`identify -format %w "${base_path}"` | |
# This overlays a horizontal band across the icon, containing information | |
# about app version, configuration name, branch name, and commit number. | |
convert -background '#FFFB' -fill black -gravity center -size ${width}x55\ | |
caption:"${version} ${CONFIGURATION} ${branch} ${commit}"\ | |
"${base_path}" +swap -gravity south -composite "${target_path}" | |
echo "Overlayed ${target_path}" | |
} | |
# Replace these with the actual filenames of all your icons | |
processIcon "app_icon_57x57_square.png" | |
processIcon "app_icon_72x72_square.png" | |
processIcon "app_icon_76x76_square.png" | |
processIcon "app_icon_114x114_square.png" | |
processIcon "app_icon_120x120_square.png" | |
processIcon "app_icon_144x144_square.png" | |
processIcon "app_icon_152x152_square.png" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment