告诉AppleScript构建XCode项目

告诉AppleScript构建XCode项目,xcode,applescript,Xcode,Applescript,以下是我想要的步骤: 启动xcode 打开特定的xcodeproj文件 构建并调试它 退出xcode 以下是我第一次尝试编写AppleScript: tell application "Xcode" tell project "iphone_manual_client" debug end tell close project "iphone_manual_client" end tell tell application "Xcode" ope

以下是我想要的步骤:

  • 启动xcode
  • 打开特定的xcodeproj文件
  • 构建并调试它
  • 退出xcode
  • 以下是我第一次尝试编写AppleScript:

    tell application "Xcode"
        tell project "iphone_manual_client"
            debug
        end tell
        close project "iphone_manual_client"
    end tell
    
    tell application "Xcode"
        open "Users:chuan:Desktop:iphone_manual_client:iphone_manual_client.xcodeproj"
        tell project "iphone_manual_client"
                clean
                build
                (* for some reasons, debug will hang even the debug process has completed. 
                   The try block is created to suppress the AppleEvent timeout error 
                 *)
                try
                    debug
                end try
        end tell
        quit
    end tell
    
    这仅在xcode打开此项目时有效。我希望只有在有必要的时候才打开该项目

    有谁能给我指出正确的方向?谢谢


    -chuan-

    有一个名为
    xcodebuild
    (手册页)的命令行实用程序,它可以更好地完成您想要完成的任务。

    我不确定AppleScript是否正确,但您可以从命令行编译它,而无需打开xcode ide,如下所示:

    xcodebuild -configuration Debug -target WhatATool -project WhatATool.xcodeproj
    

    在配置是显而易见的选项的地方,target是xcode目标列表中的名称,最后是项目名称。

    我想我已经解决了这个问题。以下是AppleScript:

    tell application "Xcode"
        tell project "iphone_manual_client"
            debug
        end tell
        close project "iphone_manual_client"
    end tell
    
    tell application "Xcode"
        open "Users:chuan:Desktop:iphone_manual_client:iphone_manual_client.xcodeproj"
        tell project "iphone_manual_client"
                clean
                build
                (* for some reasons, debug will hang even the debug process has completed. 
                   The try block is created to suppress the AppleEvent timeout error 
                 *)
                try
                    debug
                end try
        end tell
        quit
    end tell
    

    路径的格式必须为“:”而不是“/”。现在唯一的问题是,调试控制台完成工作后,AppleScript似乎“挂起”,好像在等待发生什么。我需要对AppleScript进行更多的研究,以了解脚本的错误。

    由于调试可能需要任意时间,您可能需要在调试消息周围设置一个“秒超时”/“结束超时”块。

    嗨,stefan,感谢您的回复。这将构建应用程序。我需要使用xcode的原因是它对iphone的上传和远程调试机制。除了xcode,没有命令行工具可以让我轻松地将新编译的iphone应用程序上传到真正的设备上。嗨,pgb,xcodebuild只会为我构建它。将应用程序上载到iphone并在那里进行调试对我没有帮助。你知道如何检查调试是否已经在运行吗?我在脚本的后续执行中遇到了一个问题:“无法调试可执行文件,因为调试会话正在进行”。嗨,Aaron,我想另一个选项是强制XCode完全关闭,并在运行新的测试集之前再次启动XCode?这可能会解决您面临的问题。不幸的是,Xcode 4破坏了许多Xcode AppleScript功能,包括运行和调试功能。看起来上面的脚本已经不起作用了。