Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@krimpedance
Last active December 19, 2017 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krimpedance/c670b71a6244a758cde2f5dfbaf5cb73 to your computer and use it in GitHub Desktop.
Save krimpedance/c670b71a6244a758cde2f5dfbaf5cb73 to your computer and use it in GitHub Desktop.
Create Xcode project from base project.
export LANG=C
# Check arguments
if [$# -ne 2 ]; then
echo "[Error]: 2 arguments are necessary."
echo "[Usage]: $0 TEMPLATE_NAME PROJECT_NAME"
exit 1
fi
# Parameters
templateName=$1
projectPath=$2
projectName=`basename $projectPath`
# Copy template
cp -R ~/Documents/xcode/Template/$templateName $projectPath
# Rename file and folder
paths=`find -d $projectPath -name "*$templateName*"`
for path in $paths
do
replacePath=`dirname $path`/`basename $path | sed "s/$templateName/$projectName/g"`
mv $path $replacePath
done
# Replace file texts
files=`find $projectPath -type f -print`
for file in $files
do
sed -i '' -e "s/$templateName/$projectName/g" $file
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment