Skip to content

Instantly share code, notes, and snippets.

@valeriyvan
Forked from valeriomazzeo/xcode-icon-tag.sh
Created March 19, 2018 23:59
Show Gist options
  • Save valeriyvan/d0384a540f94df9420aeb5c928ebe14e to your computer and use it in GitHub Desktop.
Save valeriyvan/d0384a540f94df9420aeb5c928ebe14e to your computer and use it in GitHub Desktop.
Xcode Icon Version Overlay
# xcode-icon-tag.sh
# The MIT License (MIT)
#
# Copyright (c) <2015> <Valerio Mazzeo>
# Permission is hereby granted, free of charge, to any person obtaining a copy
#
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# @desc Overlay the marketing version on top of the icon file. The icons are modified inside the .app package.
# For this reason, to allow image magick to process the icons is required to disable "Compress PNG Files" on the Xcode
# build settings for target that do not require the overlay. It is not recommended to disable PNG compression on production builds.
# @dependencies imagemagick ghostscript
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Select: Build Settings Tab
# 6. Select: Packaging -> Compress PNG Files
# 7. Select: Set the value to "No" for the "Debug" configuration
if [ "${CONFIGURATION}" = "Debug" ]; then
export PATH=$PATH:/usr/local/bin
VM_ICONS_PREFIX="${ASSETCATALOG_COMPILER_APPICON_NAME}"
VM_BASE_PATH="${TARGET_BUILD_DIR}/${PRODUCT_NAME}.${WRAPPER_EXTENSION}"
VM_INFO_PLIST="${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
VM_SHORT_VERSION=`defaults read "${VM_INFO_PLIST}" CFBundleShortVersionString`
find "${VM_BASE_PATH}" -type f -name "${VM_ICONS_PREFIX}*.png" -print0 | while IFS= read -r -d '' file; do
convert -background '#0008' -fill white -gravity center -size `identify -format %w "$file"` \
caption:"${VM_SHORT_VERSION}" \
"$file" +swap -gravity south -composite "$file"
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment