Skip to content
Permalink
Browse files

Created script to rename all instances of PhoneGap, and update the Ja…

…vaScript build munger appropriately
  • Loading branch information...
NachoMan committed Jun 8, 2009
1 parent 515128e commit dd5daeea79b6ee649cee209fd634e8a4c2609601
Showing with 68 additions and 3 deletions.
  1. +2 −2 iphone/Info.plist
  2. +1 −1 iphone/build-phonegap.sh
  3. +65 −0 iphone/rename-phonegap.sh
@@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>PhoneGap</string>
<string>PhoneGap Demo</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
@@ -15,7 +15,7 @@
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<string>PhoneGap</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
@@ -1,7 +1,7 @@
#!/bin/sh
set -x
PHONEGAP_LIB=$TARGET_BUILD_DIR/$CONTENTS_FOLDER_PATH/www/app.js
APPNAME=`defaults read $SOURCE_ROOT/Info CFBundleDisplayName | sed -Ee 's/[^a-zA-Z0-9]+//'`
APPNAME=`defaults read $SOURCE_ROOT/Info CFBundleName`

cd $PROJECT_DIR/..
[ -f Makefile ] && rm Makefile
@@ -0,0 +1,65 @@
#!/bin/sh

set -e

usage()
{
[ -n "$1" ] && echo $1 >&2
echo "Usage: $0 [-r] [-v] [-g] -n <name>" >&2
echo " -n Specify the name of the new project" >&2
echo " -r Rename all instances of PhoneGap; use with care, as" >&2
echo " this will make it very difficult to merge in future updates" >&2
echo " -v Enable verbose mode" >&2
echo " -g Use git to rename files" >&2
exit 1
}

renameall= verbose= usegit= appname=
while getopts :v:n:r:g ch
do
case "$ch" in
n) appname="$OPTARG";;
r) renameall=TRUE;;
g) usegit=TRUE;;
v) verbose=TRUE;;
*) usage;;
esac
done
shift $(($OPTIND - 1))

cd iphone

CMD=
[ -z "$appname" ] && usage
[ -n "$usegit" ] && CMD=git

shortname=`echo $appname | sed -E -e 's/[^a-zA-Z0-9]//g'`
[ -n "$verbose" ] && echo "Long name: $appname"
[ -n "$verbose" ] && echo "Short name: $shortname"

[ -d PhoneGap.xcodeproj ] || usage "PhoneGap.xcodeproj doesn't exist"

[ -n "$verbose" ] && set -x

xcodeproj=PhoneGap.xcodeproj/project.pbxproj
$CMD mv PhoneGap.plist $shortname.plist
sed -E -i '' -e "s/PhoneGap.plist/$shortname.plist/g" $xcodeproj
sed -E -i '' -e "s/PhoneGap.app/$shortname.app/g" $xcodeproj
sed -E -i '' -e "s/name = PhoneGap/name = \"$appname\"/g" $xcodeproj
sed -E -i '' -e "s/PRODUCT_NAME = PhoneGap/PRODUCT_NAME = $shortname/g" $xcodeproj
sed -E -i '' -e "s/productName = PhoneGap/productName = $shortname/g" $xcodeproj
sed -E -i '' -e "s/PhoneGap Demo/$appname/g" Info.plist
sed -E -i '' -e "s/PhoneGap/$shortname/g" Info.plist

if [ -n "$renameall" ]; then
sed -E -i '' -e "s/PhoneGap/$shortname/g" $xcodeproj
for file in `find . -type f -name '*.xib' -o -name '*.h' -o -name '*.m' -o -name '*.pch' | grep -v Frameworks`; do
sed -E -i '' -e "s/PhoneGap/$shortname/g" $file
newfilename=`echo $file | sed -e s/PhoneGap/$shortname/`
if [ $newfilename != $file ]; then
$CMD mv "$file" "$newfilename"
fi
done
fi

$CMD mv PhoneGap.xcodeproj $shortname.xcodeproj

0 comments on commit dd5daee

Please sign in to comment.
You can’t perform that action at this time.