Skip to content

Instantly share code, notes, and snippets.

@tettoffensive
Created February 2, 2015 20:39
Show Gist options
  • Save tettoffensive/c36783cab8935865ef2b to your computer and use it in GitHub Desktop.
Save tettoffensive/c36783cab8935865ef2b to your computer and use it in GitHub Desktop.
changing app icon script
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`
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}"
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}
}
icon_files=(`/usr/libexec/PlistBuddy -c "Print CFBundleIconFiles" ${INFOPLIST_FILE}`)
icon_count=${#icon_files[@]}
#Magic number 2 skips over "Array" and "{".
#count-1 to ignore the closing "}"
for (( i = 2; i < icon_count-1; i++ )); do
processIcon ${icon_files[$i]}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment