2

I have a complete command to deploy the xCode project on real device.

i.e

xcodebuild -workspace jamesAppV2.xcworkspace -scheme jamesAppV2 -configuration Debug -destination 'platform=iOS,name=Shujaat’s iPad' clean test

its working fine using the command line.

Todo: I wanted to execute this command via a shell script.

here is my complete shell script deploy.sh so for.

#!/bin/bash
#My First Script

#Info to be configured 


current_path=$(pwd)
appName="jamesApp"
jamesApp_workspace="jamesAppV2.xcworkspace"

echo "Searching for $jamesApp_workspace workspace..."

if [[ $(ls $jamesApp_workspace) ]];     then 
    echo "$jamesApp_workspace found in current directory."


echo "Listing all installed and connected devices..."
instruments -s devices

echo "Copy + Paste from above devices"
echo "specify name of your decice to launch $appName"
read d_device_name

echo "building workspace for $d_device_name..."

build_cmd=(xcodebuild -workspace jamesAppV2.xcworkspace -scheme jamesAppV2 -configuration Debug)
destination="'platform=iOS,name=$d_device_name'"

build_cmd+=(-destination "$destination" clean test)

echo "${build_cmd[@]}"
# Here it prints the valid command given above

"${build_cmd[@]}"

else
    echo "$jamesApp_workspace workspace not found"
    echo "Make sure your current path contains the $jamesApp_workspace workspace"
    echo "Place this file i.e deploy.sh within the directory containing $jamesApp_workspace workspace"
fi;

Problem: I have done like

build_cmd=(xcodebuild -workspace jamesAppV2.xcworkspace -scheme jamesAppV2 -configuration Debug)
destination="'platform=iOS,name=$d_device_name'" 
build_cmd+=(-destination "$destination" clean test) 
echo "${build_cmd[@]}"  #Prints valid command
"${build_cmd[@]}" 

but gives error on execution

xcodebuild: error: option 'Destination' requires at least one parameter of the form 'key=value'

if I run the above command via command line its working perfectly but If I run this via shell script its not working.

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

2 Answers 2

2

The shell removes the single quotes in the original command, therefore you should not have any when creating the array either.

Sign up to request clarification or add additional context in comments.

2 Comments

I removed the single quotes from my script. now I am getting this error xcodebuild: error: Scheme jamesAppV2 is not currently configured for the test action.. this is strange. command executes successfully from command line
@ Ignacio Vazquez-Abrams please answer this stackoverflow.com/questions/37042815/…
0

I am also trying to execute the command in a similar way by passing it via a string. The command works without the double quotes anywhere on the command for me.

example:

$ xcodebuild -project ~/ios_projects/example.xcodeproj -scheme Xcode9-XCtest destination id=EBCDFH7S-DCJD-EE8D-DSKDKD78

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.