I'm trying to build xcode project with shell, and now face a problem. the command xcodebuild has many args, and i may use some of them in some cases. I have a short example here, the destination arg has a space in it:
build_cmd='xcodebuild -project MyApp.xcodeproj'
destination="platform=iOS,name=generic/iOS Device"
if [ $# -ge 1 ];then
build_cmd=${build_cmd}' -destination '${destination}
fi
#echo $build_cmd
$build_cmd
but it failed to run, result with:
xcodebuild: error: Unknown build action 'Device'.
What's wrong here? Somebody help?
I want to give another example if you never use xcodebuild command:
filename="a b c.txt"
cmd='vi '${filename}
$cmd # i wish to open "a b c.txt", but it opens 3 files, a, b, c.txt
how to run command with args which have space?
BASH FAQ entry #50: "I'm trying to put a command in a variable, but the complex cases always fail!"