我如何通过AppleScript的传递命令行参数X code ++项目? [英] How do i pass command line arguments to Xcode project through AppleScript?

查看:910
本文介绍了我如何通过AppleScript的传递命令行参数X code ++项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置的命令行参数有关iPhone模拟器应用程序x code项目。

I am trying to set command line arguments for Xcode project related to iPhone Simulator Application.

当我尝试运行下面的脚本行
做出新的发射参数与性能{名字:文件:///Users/aakash/Desktop/sample_h.html活动:是}

When i try to run the following script the line "make new launch argument with properties{name:"file:///Users/aakash/Desktop/sample_h.html",active:yes} "

给出错误:
执行错误:X code得到了一个错误:无法拨打或该元素移动到容器中。 (-10024)

gives error: execution error: Xcode got an error: Can’t make or move that element into that container. (-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

任何线索?
是否有任何其他方式来设置X code项目参数还是我做错了?
请帮助。

Any Clues??? Is there any other way to set arguments for Xcode Project or am i doing it wrong? Please help.

推荐答案

您应积极可执行文件作为容器,而不是X code应用程序

You should make active executable as the container instead of Xcode application

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

结果这仍然适用于X code三级。*,但通过X code 4没有长期的工作。*


this still works for Xcode 3.* but no long work with Xcode 4.*

这篇关于我如何通过AppleScript的传递命令行参数X code ++项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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