Context: I'm trying to clean my Xcode workspace and scheme via the command line. I've tried both trimming the quotes and not trimming them.
The current result is: -bash: ~/my/workspace/location: No such file or directory
. But, if I run the command directly, $ xcodebuild clean -workspace ~/my/workspace/location -scheme SchemeName
, it works just fine.
Here's what I've got so far:
cxc () {
local path_to_workspace="~/my/workspace/location"
local scheme="SchemeName"
if [ ! -z "$1" ]; then
path_to_workspace="$1"
fi
if [ ! -z "$2" ]; then
scheme="$2"
fi
if [ -z "$1" ]; then
echo "No arguments supplied. Using default."
fi
# Trim quotes from URL
path_to_workspace=$("$path_to_workspace" | tr -d \")
xcodebuild clean -workspace "$path_to_workspace" -scheme "$scheme"
}