Skip to content

Commit

Permalink
Icon stamping
Browse files Browse the repository at this point in the history
Separate bundle IDs and drawing of version and branch on icon, taken from KZBootstrap
  • Loading branch information
alexcurylo committed Dec 27, 2014
1 parent 07f504f commit a54cb39
Show file tree
Hide file tree
Showing 18 changed files with 212 additions and 27 deletions.
8 changes: 5 additions & 3 deletions PoseGallery/PoseGallery.xcodeproj/project.pbxproj
Expand Up @@ -41,7 +41,7 @@
FA44C9DC1A499BCE00776BD6 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../../README.md; sourceTree = "<group>"; };
FA44C9E01A4DE7E900776BD6 /* .travis.yml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = .travis.yml; path = ../../.travis.yml; sourceTree = "<group>"; };
FA44CA151A4E0D0600776BD6 /* .slather.yml */ = {isa = PBXFileReference; lastKnownFileType = text; name = .slather.yml; path = ../../.slather.yml; sourceTree = "<group>"; };
FA6E64A11A279B7700395E94 /* Poses Pro.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Poses Pro.app"; sourceTree = BUILT_PRODUCTS_DIR; };
FA6E64A11A279B7700395E94 /* Poses Pro.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Poses Pro.app"; sourceTree = BUILT_PRODUCTS_DIR; };
FA6E64A51A279B7700395E94 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
FA6E64A61A279B7700395E94 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
FA6E64A81A279B7700395E94 /* FirstViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirstViewController.swift; sourceTree = "<group>"; };
Expand All @@ -57,6 +57,7 @@
FAB13EF71A3878850053620A /* project_PoseGallery.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = project_PoseGallery.xcconfig; sourceTree = "<group>"; };
FAB13EFF1A3878850053620A /* target_PoseGallery.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = target_PoseGallery.xcconfig; sourceTree = "<group>"; };
FAB13F001A3878850053620A /* target_PoseGalleryTests.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = target_PoseGalleryTests.xcconfig; sourceTree = "<group>"; };
FAD9A7E01A4E5D70000DE885 /* script_tag_icon.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = script_tag_icon.sh; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -120,7 +121,7 @@
FA6E64A21A279B7700395E94 /* Products */ = {
isa = PBXGroup;
children = (
FA6E64A11A279B7700395E94 /* Poses Pro.app */,
FA6E64A11A279B7700395E94 /* Poses Pro.app */,
FA6E64B81A279B7800395E94 /* "PoseGalleryTests".xctest */,
);
name = Products;
Expand Down Expand Up @@ -179,6 +180,7 @@
children = (
FAB13EF41A3878850053620A /* script_build_begin.sh */,
FAB13EF51A3878850053620A /* script_build_end.sh */,
FAD9A7E01A4E5D70000DE885 /* script_tag_icon.sh */,
FAB13EF71A3878850053620A /* project_PoseGallery.xcconfig */,
FAB13EFF1A3878850053620A /* target_PoseGallery.xcconfig */,
FAB13F001A3878850053620A /* target_PoseGalleryTests.xcconfig */,
Expand Down Expand Up @@ -209,7 +211,7 @@
);
name = PoseGallery;
productName = PoseGallery;
productReference = FA6E64A11A279B7700395E94 /* Poses Pro.app */;
productReference = FA6E64A11A279B7700395E94 /* Poses Pro.app */;
productType = "com.apple.product-type.application";
};
FA6E64B71A279B7800395E94 /* PoseGalleryTests */ = {
Expand Down
@@ -1,8 +1,9 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"idiom" : "iphone",
"filename" : "icon-58.png",
"scale" : "2x"
},
{
Expand All @@ -11,18 +12,21 @@
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"idiom" : "iphone",
"filename" : "icon-80.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"idiom" : "iphone",
"filename" : "icon-120.png",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"idiom" : "iphone",
"filename" : "icon-120-1.png",
"scale" : "2x"
},
{
Expand All @@ -31,33 +35,39 @@
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"idiom" : "ipad",
"filename" : "icon-29-1.png",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"idiom" : "ipad",
"filename" : "icon-58-1.png",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"idiom" : "ipad",
"filename" : "icon-40.png",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"idiom" : "ipad",
"filename" : "icon-80-1.png",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"idiom" : "ipad",
"filename" : "icon-76.png",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"idiom" : "ipad",
"filename" : "icon-152.png",
"scale" : "2x"
}
],
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -5,7 +5,21 @@
// Copyright (c) 2015 Trollwerks Inc. All rights reserved.
//

PRODUCT_NAME = Poses Pro
// for simultaneous install of each configuration

BUNDLE_ID_SUFFIX = $(BUNDLE_ID_SUFFIX_$(CONFIGURATION))
BUNDLE_ID_SUFFIX_Debug = .debug
BUNDLE_ID_SUFFIX_Adhoc = .adhoc
BUNDLE_ID_SUFFIX_Release =

BUNDLE_DISPLAY_NAME_SUFFIX = $(BUNDLE_DISPLAY_NAME_SUFFIX_$(CONFIGURATION))
BUNDLE_DISPLAY_NAME_SUFFIX_Debug = ∆
BUNDLE_DISPLAY_NAME_SUFFIX_Adhoc = ß
BUNDLE_DISPLAY_NAME_SUFFIX_Release =

// base branding

PRODUCT_NAME = Poses Pro$(BUNDLE_DISPLAY_NAME_SUFFIX)
PRODUCT_VERSION_STRING = 3.0
PRODUCT_BUNDLE_VERSION = 66
PRODUCT_BUNDLE_IDENTIFIER = com.trollwerks.posespro
PRODUCT_BUNDLE_VERSION = 1
PRODUCT_BUNDLE_IDENTIFIER = com.trollwerks.posespro$(BUNDLE_ID_SUFFIX)
4 changes: 1 addition & 3 deletions PoseGallery/PoseGalleryConfig/project_PoseGallery.xcconfig
Expand Up @@ -6,13 +6,11 @@
//

// for Slather's coveralls.io support

//# https://github.com/venmo/slather/issues/39 -- track Swift support status
GCC_GENERATE_TEST_COVERAGE_FILES = NO
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO

// read http://danwright.info/blog/2012/10/xcode-build-configurations/ about new debug/release format to see if it's Xcode 5 friendly


// Environment and processing management

//SDKROOT = iphoneos
Expand Down
8 changes: 7 additions & 1 deletion PoseGallery/PoseGalleryConfig/script_build_begin.sh
Expand Up @@ -9,7 +9,13 @@

# Crashlytics magic

./PoseGallery/libraries/Fabric.framework/run 186ef2a41f30e2ce39a21f35b61600d3ae927290 3ce3168d4276f7278273f34fbc45d96dd492c71a98dc7a3dcd8f1fc3da321e50
#./PoseGallery/libraries/Fabric.framework/run 186ef2a41f30e2ce39a21f35b61600d3ae927290 3ce3168d4276f7278273f34fbc45d96dd492c71a98dc7a3dcd8f1fc3da321e50

# icon tagging

if [ $CONFIGURATION != "Release" ] ; then
${SRCROOT}/PoseGalleryConfig/script_tag_icon.sh tag PoseGallery/resources/Images.xcassets/AppIcon.appiconset
fi

# finished

Expand Down
6 changes: 3 additions & 3 deletions PoseGallery/PoseGalleryConfig/script_build_end.sh
Expand Up @@ -36,10 +36,10 @@ echo Build date set to current date: $CFBuildDate

# https://gist.github.com/dulaccc/a52154ac4c007db2be55

update_icon()
restore_icon()
{
if [ $CONFIGURATION != "Release" ] ; then
${SRCROOT}/PoseGallery/PoseGalleryConfig/tag_icons.sh tag YourApp/Images.xcassets/AppIcon.appiconset
${SRCROOT}/PoseGalleryConfig/script_tag_icon.sh cleanup PoseGallery/resources/Images.xcassets/AppIcon.appiconset
fi
}

Expand All @@ -56,7 +56,7 @@ find -L ${SRCROOT}// -type f -not -name “.*” -not -name “`basename ${INFOP
echo Setting info in plist $plist:
update_bundle_version
update_build_date
#update_icon
restore_icon
#copy_branding

# reveal the binary in the Finder if you like
Expand Down
153 changes: 153 additions & 0 deletions PoseGallery/PoseGalleryConfig/script_tag_icon.sh
@@ -0,0 +1,153 @@
#!/bin/sh

#
# script_tag_icon.sh
# from iconVersioning.h, https://github.com/krzysztofzablocki/KZBootstrap
#

export PATH=/opt/local/bin/:/opt/local/sbin:$PATH:/usr/local/bin:

convertPath=`which convert`
echo ${convertPath}
if [[ ! -f ${convertPath} || -z ${convertPath} ]]; then
echo "WARNING: Skipping Icon versioning, you need to install ImageMagick and ghostscript (fonts) first, you can use brew to simplify process:
brew install imagemagick
brew install ghostscript"
exit 0;
fi

git=`sh /etc/profile; which git`
build_num=`"$git" rev-list --all |wc -l`
branch=`"$git" rev-parse --abbrev-ref HEAD`
commit=`"$git" rev-parse --short HEAD`
#version=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${INFOPLIST_FILE}"`
version=${PRODUCT_VERSION_STRING}

#DIR="${BASH_SOURCE%/*}"
#if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
#. "$DIR/buildNumber.sh"

branch="${branch}->${BUNDLE_DISPLAY_NAME_SUFFIX}"

#SRCROOT=..
#CONFIGURATION_BUILD_DIR=.
#UNLOCALIZED_RESOURCES_FOLDER_PATH=.

#commit="3783bab"
#branch="master"
#version="3.4"
#build_num="9999"

shopt -s extglob
build_num="${build_num##*( )}"
shopt -u extglob
caption="${version} ($build_num)\n${branch}\n${commit}"
echo $caption

function abspath() { pushd . > /dev/null; if [ -d "$1" ]; then cd "$1"; dirs -l +0; else cd "`dirname \"$1\"`"; cur_dir=`dirs -l +0`; if [ "$cur_dir" == "/" ]; then echo "$cur_dir`basename \"$1\"`"; else echo "$cur_dir/`basename \"$1\"`"; fi; fi; popd > /dev/null; }

function processIcon() {
base_file=$1

cd "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
base_path=`find . -name ${base_file}`

real_path=$( abspath "${base_path}" )
echo "base path ${real_path}"

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

# TODO: if they are the same we need to fix it by introducing temp
target_file=`basename $base_path`
target_path="${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/${target_file}"

base_tmp_normalizedFileName="${base_file%.*}-normalized.${base_file##*.}"
base_tmp_path=`dirname $base_path`
base_tmp_normalizedFilePath="${base_tmp_path}/${base_tmp_normalizedFileName}"

stored_original_file="${base_tmp_normalizedFilePath}-tmp"
if [[ -f ${stored_original_file} ]]; then
echo "found previous file at path ${stored_original_file}, using it as base"
mv "${stored_original_file}" "${base_path}"
fi

if [ $CONFIGURATION = "Release" ]; then
cp "${base_path}" "$target_path"
return 0;
fi

echo "Reverting optimized PNG to normal"
# Normalize
echo "xcrun -sdk iphoneos pngcrush -revert-iphone-optimizations -q ${base_path} ${base_tmp_normalizedFilePath}"
xcrun -sdk iphoneos pngcrush -revert-iphone-optimizations -q "${base_path}" "${base_tmp_normalizedFilePath}"

# move original pngcrush png to tmp file
echo "moving pngcrushed png file at ${base_path} to ${stored_original_file}"
#rm "$base_path"
mv "$base_path" "${stored_original_file}"

# Rename normalized png's filename to original one
echo "Moving normalized png file to original one ${base_tmp_normalizedFilePath} to ${base_path}"
mv "${base_tmp_normalizedFilePath}" "${base_path}"

width=`identify -format %w ${base_path}`
height=`identify -format %h ${base_path}`
band_height=$((($height * 47) / 100))
band_position=$(($height - $band_height))
text_position=$(($band_position - 3))
point_size=$(((13 * $width) / 100))

echo "Image dimensions ($width x $height) - band height $band_height @ $band_position - point size $point_size"

#
# blur band and text
#
convert ${base_path} -blur 10x8 /tmp/blurred.png
convert /tmp/blurred.png -gamma 0 -fill white -draw "rectangle 0,$band_position,$width,$height" /tmp/mask.png
convert -size ${width}x${band_height} xc:none -fill 'rgba(0,0,0,0.2)' -draw "rectangle 0,0,$width,$band_height" /tmp/labels-base.png
convert -background none -size ${width}x${band_height} -pointsize $point_size -fill white -gravity center -gravity South caption:"$caption" /tmp/labels.png

convert ${base_path} /tmp/blurred.png /tmp/mask.png -composite /tmp/temp.png

rm /tmp/blurred.png
rm /tmp/mask.png

#
# compose final image
#
filename=New${base_file}
convert /tmp/temp.png /tmp/labels-base.png -geometry +0+$band_position -composite /tmp/labels.png -geometry +0+$text_position -geometry +${w}-${h} -composite "${target_path}"

# clean up
rm /tmp/temp.png
rm /tmp/labels-base.png
rm /tmp/labels.png

echo "Overlayed ${target_path}"
}

icon_count=`/usr/libexec/PlistBuddy -c "Print CFBundleIcons:CFBundlePrimaryIcon:CFBundleIconFiles" "${CONFIGURATION_BUILD_DIR}/${INFOPLIST_PATH}" | wc -l`
last_icon_index=$((${icon_count} - 2))

i=0
while [ $i -lt $last_icon_index ]; do
icon=`/usr/libexec/PlistBuddy -c "Print CFBundleIcons:CFBundlePrimaryIcon:CFBundleIconFiles:$i" "${CONFIGURATION_BUILD_DIR}/${INFOPLIST_PATH}"`

if [[ $icon == *.png ]] || [[ $icon == *.PNG ]]
then
processIcon $icon
else
processIcon "${icon}.png"
processIcon "${icon}@2x.png"
fi
let i=i+1
done

# Workaround to fix issue#16 to use wildcard * to actually find the file
# Only 72x72 and 76x76 that we need for ipad app icons
processIcon "AppIcon72x72~ipad*"
processIcon "AppIcon72x72@2x~ipad*"
processIcon "AppIcon76x76~ipad*"
processIcon "AppIcon76x76@2x~ipad*"
10 changes: 6 additions & 4 deletions README.md
@@ -1,8 +1,10 @@
[![Build Status](https://travis-ci.org/alexcurylo/swift-pose-gallery.svg?branch=master)](https://travis-ci.org/alexcurylo/swift-pose-gallery) <!---
# https://github.com/venmo/slather/issues/39 -- track Swift support status
[![Coverage Status](https://coveralls.io/repos/alexcurylo/swift-pose-gallery/badge.png)](https://coveralls.io/r/alexcurylo/swift-pose-gallery)
--> [![Stories in Ready](https://badge.waffle.io/alexcurylo/swift-pose-gallery.png?label=ready&title=Ready)](https://waffle.io/alexcurylo/swift-pose-gallery)
[![Build Status](https://travis-ci.org/alexcurylo/swift-pose-gallery.svg?branch=master)](https://travis-ci.org/alexcurylo/swift-pose-gallery)
[![Stories in Ready](https://badge.waffle.io/alexcurylo/swift-pose-gallery.png?label=ready&title=Ready)](https://waffle.io/alexcurylo/swift-pose-gallery)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/alexcurylo/swift-pose-gallery?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
<!---
# https://github.com/venmo/slather/issues/39 -- track Swift support status
[![Coverage Status](https://coveralls.io/repos/alexcurylo/swift-pose-gallery/badge.png)](https://coveralls.io/r/alexcurylo/swift-pose-gallery)
-->

swift-pose-gallery
==================
Expand Down

0 comments on commit a54cb39

Please sign in to comment.