Skip to content

Instantly share code, notes, and snippets.

@csknns
Created February 4, 2015 15:59
Show Gist options
  • Save csknns/c6644f70696f5b154d6a to your computer and use it in GitHub Desktop.
Save csknns/c6644f70696f5b154d6a to your computer and use it in GitHub Desktop.
commit=`git rev-parse --short HEAD`
branch=`git rev-parse --abbrev-ref HEAD`
build=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${INFOPLIST_FILE}"`
version=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${INFOPLIST_FILE}"`
function processIcon() {
export PATH=$PATH:/usr/local/bin
base_file=$1
base_path=`find ${SRCROOT}/DominosOrder -name $base_file`
flag_image=`find ${SRCROOT}/DominosOrder -name top_left_flag.png`
echo "base path ${base_path}"
# echo "flag_image path ${flag_image}"
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 "base_file ${base_file}"
echo "target_path ${target_path}"
if [!`which identify` || !`which convert`]; then
echo "ImageMagick not found"
return;
fi
# do not run in Release mode
if [ $CONFIGURATION = "Release" ]; then
echo "Release configuration just coping the icon"
cp ${base_path} ${target_path}
return
fi
width=`/opt/local/bin/identify -format %w ${base_path}`
/opt/local/bin/convert -background '#0008' -fill white -gravity center -size ${width}x30 caption:"${version}(${build})beta" ${base_path} +swap -gravity south -composite ${target_path}
echo "flag_image ${flag_image}"
echo "target_path ${target_path}"
if [[ -f ${flag_image} && ! -z ${flag_image} ]]; then
/opt/local/bin/composite -geometry +10+10 ${flag_image} ${target_path} ${target_path}
fi
}
processIcon "AppIcon60x60@2x_base.png"
processIcon "AppIcon76x76@2x~ipad_base.png"
processIcon "AppIcon76x76~ipad_base.png"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment