#! /bin/sh 
# (c) 2015 Mulle kybernetiK
# coded by Nat!
#
SRC=icon/TemplateIcon.png
TMPSET=/tmp/umbrella-icon.iconset

mkdir -p "${TMPSET}" 2> /dev/null

sips -z 16 16 "$SRC" --out "${TMPSET}"/icon_16x16.png > /dev/null
sips -z 32 32 "$SRC" --out "${TMPSET}"/icon_16x16@2x.png > /dev/null
sips -z 32 32 "$SRC" --out "${TMPSET}"/icon_32x32.png > /dev/null
sips -z 64 64 "$SRC" --out "${TMPSET}"/icon_32x32@2x.png > /dev/null
cp "$SRC" "$TMPSET"/icon_64x64@2x.png
cp "$SRC" "$TMPSET"/icon_128x128.png

iconutil -o "Umbrella Framework.xctemplate/TemplateIcon.icns" -c icns "$TMPSET" 2> /dev/null
if [ $? -ne 0 ]
then
   echo "icon generation failed" >&2
   exit 1
fi
cp "Umbrella Framework.xctemplate/TemplateIcon.icns" "Umbrella Framework Symlinks.xctemplate/TemplateIcon.icns"

mkdir -p ~/Library/Developer/Xcode/Templates/Project\ Templates/Mac/Framework\ \&\ Library/ 2> /dev/null
cp -Ra Umbrella\ Framework*.xctemplate ~/Library/Developer/Xcode/Templates/Project\ Templates/Mac/Framework\ \&\ Library/