我正在尝试为与iPhone模拟器应用程序相关的Xcode项目设置命令行参数。
当我尝试运行以下脚本时 “使用属性创建新的启动参数{name:”file:///Users/aakash/Desktop/sample_h.html“,active:yes}”
给出错误: 执行错误:Xcode出错:无法将该元素制作或移动到该容器中。 (-10024)
这是脚本:
!/bin/zsh
BUILD_PATH=$(dirname $0)
while [[ -z $BUILD_FILE && $BUILD_PATH != "/" ]]; do
BUILD_FILE=$(find $BUILD_PATH -name '*.xcodeproj' -maxdepth 1)
BUILD_PATH=$(dirname $BUILD_PATH)
done
if [[ -z $BUILD_FILE ]]; then
echo "Couldn't find an xcode project file in directory"
exit 1
fi
open -a Xcode "$BUILD_FILE"
BUILD_FILE=${BUILD_FILE//\//:}
SIMULATOR_SDKS=( /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/*.sdk )
SIMULATOR_SDK=${SIMULATOR_SDKS[-1]}
SIMULATOR_SDK_STRING=$(basename ${(L)SIMULATOR_SDK%.[a-z]*})
if [[ -z $SIMULATOR_SDK ]]; then
echo "Couldn't find a simulator SDK"
exit 1
fi
echo $BUILD_FILE
echo $BUILD_PATH
osascript <<SCRIPT
application "iPhone Simulator" quit
application "iPhone Simulator" activate
tell application "Xcode"
open "$BUILD_FILE"
set targetProject to project of active project document
tell targetProject
set active build configuration type to build configuration type "Debug"
set active SDK to "$SIMULATOR_SDK_STRING"
set value of build setting "SDKROOT" of build configuration "Debug" of active target to "$SIMULATOR_SDK"
make new launch argument with properties{name:"file:///Users/aakash/Desktop/sample_h.html",active:no}
if (build targetProject) is equal to "Build succeeded" then
launch targetProject
else
application "iPhone Simulator" quit
end if
end tell
end tell
SCRIPT
任何线索??? 有没有其他方法为Xcode Project设置参数或我做错了吗? 请帮忙。
答案 0 :(得分:0)
对于从命令行构建,我通常使用Makefile启动xcodebuild,即Xcode的命令行前端。如果您愿意,也可以使用zsh脚本执行相同的操作。使用命令行工具设置项目构建选项非常简单。
答案 1 :(得分:0)
您应该将活动可执行文件作为容器而不是Xcode应用程序
tell application "Xcode"
set targetProject to project of active project document
set targetExecutable to active executable of targetProject
tell targetExecutable
make new launch argument with properties {name:"new argument", active:true}
end tell
end tell
这仍适用于Xcode 3. *但不能长时间使用Xcode 4。*