#! /bin/sh # # create a phonegap/ios project # # USAGE # ./create [path package name] # # EXAMPLE # ./create ~/Desktop/radness com.phonegap.radness Radness # set -e PROJECT_PATH=${1:-"./example"} PACKAGE=${2:-"com.phonegap.example"} ACTIVITY=${3:-"PhoneGapExample"} # clobber any existing example if [ $# -eq 0 ] then rm -rf $PROJECT_PATH fi # copy the bitch in; and then rough it up cp -r ./bin/templates/project $PROJECT_PATH # I've tried to be thorough in my documentation of the manual actions below... # on first brush it would seem that the right solution would be to brute force # recurse the directory tree renaming instances of __ID__ and __TESTING__ ...however this is a little blunt # and while so the below is too being very manual it was/is easier to test, fucking manually, and sort out the automation # rename the folders/files: # # - ./__TESTING__.xcodeproj/ # - ./__TESTING__/ # - ./__TESTING__/__TESTING__-info.plist # - ./__TESTING__/__TESTING__-Prefix.plist mv $PROJECT_PATH/__TESTING__.xcodeproj $PROJECT_PATH/$ACTIVITY.xcodeproj mv $PROJECT_PATH/__TESTING__ $PROJECT_PATH/$ACTIVITY mv $PROJECT_PATH/$ACTIVITY/__TESTING__-info.plist $PROJECT_PATH/$ACTIVITY/$ACTIVITY-info.plist mv $PROJECT_PATH/$ACTIVITY/__TESTING__-Prefix.pch $PROJECT_PATH/$ACTIVITY/$ACTIVITY-Prefix.pch # lets store a reference to the root R=$PROJECT_PATH/$ACTIVITY # replace __TESTING__ and --ID-- with ACTIVITY and ID strings, respectively, in: # # - ./__TESTING__.xcodeproj/project.pbxproj # - ./__TESTING__/Classes/AppDelegate.h # - ./__TESTING__/Classes/AppDelegate.m # - ./__TESTING__/Resources/main.m # - ./__TESTING__/Resources/__TESTING__-info.plist # - ./__TESTING__/Resources/__TESTING__-Prefix.plist ./bin/replaces $R.xcodeproj/project.pbxproj __TESTING__ $ACTIVITY ./bin/replaces $R/Classes/AppDelegate.h __TESTING__ $ACTIVITY ./bin/replaces $R/Classes/AppDelegate.m __TESTING__ $ACTIVITY ./bin/replaces $R/main.m __TESTING__ $ACTIVITY ./bin/replaces $R/$ACTIVITY-info.plist __TESTING__ $ACTIVITY ./bin/replaces $R/$ACTIVITY-Prefix.pch __TESTING__ $ACTIVITY ./bin/replaces $R/$ACTIVITY-info.plist --ID-- $PACKAGE