Skip to content

Instantly share code, notes, and snippets.

@chasseurmic
Created February 11, 2014 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chasseurmic/8944551 to your computer and use it in GitHub Desktop.
Save chasseurmic/8944551 to your computer and use it in GitHub Desktop.
Xcode 5 build phase to watermark icon with ImageMagick when using new .xcassets
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}
}
processIcon "AppIcon60x60@2x.png"
@natanrolnik
Copy link

Are you able to see the results from this run script? For me it returns here:

if [[ ! -f ${base_path} || -z ${base_path} ]]; then
return;
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment