Skip to content

Instantly share code, notes, and snippets.

@dominik-hadl
Created February 8, 2014 12:12
Show Gist options
  • Save dominik-hadl/8882741 to your computer and use it in GitHub Desktop.
Save dominik-hadl/8882741 to your computer and use it in GitHub Desktop.
This gist is heavily based on this article (http://www.merowing.info/2013/03/overlaying-application-version-on-top-of-your-icon/), but with some modifications. Specifically, it support the icons stored in .xcassets and also there is now no need to have duplicate files (with _base extension). It just modifies the final copied files if the current…
branch=`git rev-parse --abbrev-ref HEAD`
version=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${INFOPLIST_FILE}"`
build=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${INFOPLIST_FILE}"`
function processIcon()
{
export PATH=$PATH:/usr/local/bin
target_file="${1}"
if [[ ! -f ${target_file} || -z ${target_file} ]]; then
return;
fi
if [ $CONFIGURATION = "Release" ]; then
return
fi
width=`identify -format %w "${target_file}"`
convert -background '#0008' -fill white -gravity center -size ${width}x40\
caption:"${version} (${build}) ${branch}"\
"${target_file}" +swap -gravity south -composite "${target_file}"
}
find "${BUILT_PRODUCTS_DIR}" -regex '.*\/AppIcon.*\.png' -type f -print0 | while IFS= read -r -d $'\0' line; do
processIcon "$line" | sed 's/^..//'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment