I want to concatenate arguments of xcodebuild as string, which have space in it ,then run this comma


I'm trying to build xcode project with shell, and now face a problem. the command <strong>xcodebuild</strong> has many args, and i may use some of them in some cases. I have a short example here, the <strong>destination</strong> 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?

<hr />

I want to give another example <strong>if you never use xcodebuild</strong> 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?


<a href="http://mywiki.wooledge.org/BashFAQ/050" rel="nofollow">BASH FAQ entry #50: "I'm trying to put a command in a variable, but the complex cases always fail!"</a>

#!/bin/bash build_cmd=(xcodebuild -project MyApp.xcodeproj) destination="platform=iOS,name=generic/iOS Device" if [ $# -ge 1 ];then build_cmd+=(-destination "$destination") fi "${build_cmd[@]}"


  • module cordova/plugin/ios/nativecomm not found - PhoneGap 2.1 / Sencha 2.0
  • cocoapods activesupport conflicts ios development
  • File Appear on Untracked list Git Commit but not on Git Status
  • MonoTouch .xcodeproj cannot be opened because the project file cannot be parsed
  • .NET RIA Services and Custom Data Model - CRUD Capabilities
  • JsonConvert.DeserializeObject, Index was outside the bounds of the array
  • Apple Reachability Notifications for Network OR Wi-Fi
  • angularjs - ng-show doesn't update class when $interval triggers
  • Reusing try catch for wcf call
  • storing drop-down values, what is a good approach
  • docker-compose: connection refused between containers, but service accessible from host
  • k-ary Trees in Java
  • Django Class view didn't return an HttpResponse object. It returned None instead
  • C#, “Object reference not set to an instance of an object.” error
  • Exception while trying to make Hazelcast cluster work with JCache compliant client
  • Finding All Combinations (cartesian product) of list values in vb.net
  • Django: DRY principle and UserPassesTestMixin
  • Consuming a web service with the Netbeans Platform
  • string.IsNullOrEmpty() Doesn't Seem to Work on a String within a Class within a Class
  • How to open multiple instances of a program in Linux
  • Trying to string.Join an IList
  • Android Database Error - getWriteableDatabase
  • Facebook iOS SDK Not Calling Completion Handler
  • How to use Windows Media Foundation with UWP without a topology
  • C# fibonacci function returning errors
  • Django model inheritance, filtering models
  • Jenkins: FATAL: Could not initialize class hudson.util.ProcessTree$UnixReflection
  • How to add git credentials to the build so it would be able to be used within a shell code?
  • Remove final comma from string in vb.net
  • x64 applications using gdi+: what are the consequences on performance?
  • Custom Tabgroup Appcelerator
  • How to do unit test for HttpContext.Current.Server.MapPath
  • If I include Java 8 in my Android app does that affect which devices it will work on?
  • Sails.js/waterline: Executing waterline queries in toJSON function of a model?
  • Splitting given String into two variables - php
  • JavaScriptCore crash on iOS9
  • Display Images one by one with next and previous functionality
  • Upload files with Ajax and Jquery
  • 0x202A in filename: Why?
  • How does Linux kernel interrupt the application?