【发布时间】:2016-05-05 05:08:27
【问题描述】:
我有一个完整的命令可以在真机上部署 xCode 项目。
即
xcodebuild -workspace jamesAppV2.xcworkspace -scheme jamesAppV2 -configuration Debug -destination 'platform=iOS,name=Shujaat’s iPad' clean test
使用命令行可以正常工作。
待办事项: 我想通过 shell 脚本执行这个命令。
这是我完整的 shell 脚本 deploy.sh 所以。
#!/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[@]}"
但执行时出错
xcodebuild: error: option 'Destination' requires at least one parameter of the form 'key=value'
如果我通过命令行运行上述命令,它可以正常工作,但如果我通过 shell 脚本运行它,它就不能正常工作。
我已推荐I want to concatenate arguments of xcodebuild as string, which have space in it ,then run this command 连接 xcodebuild 命令
【问题讨论】:
标签: ios bash shell command-line xcodebuild