在shell脚本的iOS X codebuild命令 [英] xcodebuild command in shell script iOS

查看:437
本文介绍了在shell脚本的iOS X codebuild命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个完整的命令部署真实设备的X code项目。

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

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: 我想通过一个shell脚本来执行此命令

这里是我的完整shell脚本 deploy.sh 所以

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;

问题:
我做了像

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'

如果我通过命令行运行上面的命令其完美的工作,但如果我通过shell脚本来运行这个它不工作。

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

我已经提到<一个href=\"http://stackoverflow.com/questions/25561370/i-want-to-concatenate-arguments-of-x$c$cbuild-as-string-which-have-space-in-it/25561469#comment61609751_25561469\">I想连接X codebuild参数为字符串,它有空间,那么运行这个命令来连接在X codebuild命令

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

推荐答案

壳去除原命令的单引号,因此,你也不应该创建阵列的时候有任何

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

这篇关于在shell脚本的iOS X codebuild命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆