Skip to content

Commit 9843b1d

Browse files
committed
Initial implementation.
1 parent ac03520 commit 9843b1d

File tree

5 files changed

+474
-1
lines changed

5 files changed

+474
-1
lines changed

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
1+
12
XcodeIconTagger
23
===============
34

4-
Adds version and commit hash as an overlay to your iOS app's icon.
5+
The XcodeIconTagger can add a version number and a GIT commit hash (or any other text) as an overlay to your iOS app's icon. This can be really useful for beta/AdHoc builds, just a glimpse at Springboard can reveal which version of your app is installed on a device! The idea for this tool came from Evan Doll who presented it at NSConference #5 as a part of development setup that Flipboard is using.
6+
7+
## Usage
8+
9+
The entry point of the tagger is tagIcons.sh script, which takes two arguments:
10+
11+
tagIcons.sh <command> [path-to-icons-directory]
12+
13+
The two available commands are:
14+
15+
* _tag_ - tags icons with version number and commit hash
16+
* _cleanup_ - checkouts the icons to their original state
17+
18+
The script is designed to be run as one of Xcode build phases. It uses environmental variables to retrieve application version and icons file names from application's Info Plist file (since the plist doesn't include full paths you still need to provide the base path to icons directory).
19+
20+
The easiest way to integrate XcodeIconTagger with your project is by adding two scripts to build phases, one at the very beginning:
21+
22+
if [ $CONFIGURATION == "Release" ] ; then
23+
${SRCROOT}/XcodeIconTagger/tagIcons.sh tag MyApp/Images
24+
fi
25+
26+
and one at the very end:
27+
28+
if [ $CONFIGURATION == "Release" ] ; then
29+
${SRCROOT}/XcodeIconTagger/tagIcons.sh cleanup MyApp/Images
30+
fi

tagIcons.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
commit=`git rev-parse --short HEAD`
4+
version=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${INFOPLIST_FILE}"`
5+
6+
mode=$1
7+
tagMode="tag"
8+
cleanupMode="cleanup"
9+
10+
iconsDirectory=`cd $2 && pwd`
11+
icons=(`/usr/libexec/PlistBuddy -c "Print CFBundleIconFiles" "${INFOPLIST_FILE}" | grep png | tr -d '\n'`)
12+
13+
taggerDirectory=`dirname $0`
14+
taggerPlist="tagImage.workflow/Contents/document.wflow"
15+
paramsPath=":actions:0:action:ActionParameters"
16+
17+
iconsCount=${#icons[*]}
18+
for (( i=0; i<iconsCount; i++ ))
19+
do
20+
icon="$iconsDirectory/${icons[$i]}"
21+
22+
if [ -f $icon ]; then
23+
height=`sips -g pixelHeight $icon | tail -n 1 | sed "s/ *pixelHeight: */ /"`
24+
width=`sips -g pixelWidth $icon | tail -n 1 | sed "s/ *pixelWidth: */ /"`
25+
26+
if (( $height == $width )); then
27+
if [ $mode == $tagMode ]; then
28+
renderSize=$(( $width * 4 )) # for some reason it looks much better when rendering canvas are bigger than an icon
29+
renderSize=$(( $renderSize + $width%2 )) # rendering canvas for odd sized images should also be odd
30+
31+
cd $taggerDirectory
32+
/usr/libexec/PlistBuddy -c "Set $paramsPath:renderPixelsHigh $renderSize" -c "Set $paramsPath:renderPixelsWide $renderSize" $taggerPlist
33+
automator -D text=$version$'\n'$commit -D image=$icon -i tagImage.qtz tagImage.workflow > /dev/null
34+
git checkout $taggerPlist
35+
36+
sips --cropToHeightWidth $height $width tagImage.png > /dev/null
37+
mv tagImage.png $icon
38+
elif [ $mode == $cleanupMode ]; then
39+
git checkout $icon
40+
fi
41+
fi
42+
fi
43+
done

tagImage.qtz

43.1 KB
Binary file not shown.
43.8 KB
Loading

0 commit comments

Comments
 (0)