Skip to content

Instantly share code, notes, and snippets.

@mitchcohen
Created May 24, 2013 12:31
Show Gist options
  • Save mitchcohen/5643177 to your computer and use it in GitHub Desktop.
Save mitchcohen/5643177 to your computer and use it in GitHub Desktop.
Xcode prebuild script to burn git info into iOS app icon. Based on https://github.com/krzysztofzablocki/IconOverlaying and http://merowing.info/2013/03/overlaying-application-version-on-top-of-your-icon/, but moved into gist with some changes. Basics - rename your icons from Icon.png to Icon_base.png (etc).
# Burns build info into app icon
# exit 0
# NOTE: This should still copy icons if git and convert are not installed...
# first, confirm git and convert (ImageMagick) exist
hash git 2>/dev/null || { echo >&2 "Git required, not installed. Aborting icon burn script."; exit 0; }
hash /usr/local/bin/convert 2>/dev/null || { echo >&2 "Convert required, not installed. Aborting icon burn script."; exit 0; }
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="appNameOrWhatever/Resources/Images/Icons/"$base_file
if [[ ! -f ${base_path} || -z ${base_path} ]]; then
return;
fi
target_file=`echo $base_file | sed "s/_base//"`
target_path="${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/${target_file}"
# echo ${target_path}
if [ $CONFIGURATION = "Release" ]; then
cp ${base_file} $target_path
return
fi
width=`identify -format %w ${base_path}`
convert -background '#0008' -fill white -gravity center -size ${width}x40\
caption:"${version} ${branch} ${commit}"\
${base_path} +swap -gravity south -composite ${target_path}
}
processIcon "Icon_base.png"
processIcon "Icon@2x_base.png"
processIcon "Icon-72_base.png"
processIcon "Icon-72@2x_base.png"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment