告诉 AppleScript 构建 XCode 项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1007082/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:37:13  来源:igfitidea点击:

Tell AppleScript To Build XCode Project

xcodeapplescript

提问by chuan

The following are the steps I would like to have:

以下是我想要的步骤:

  1. launch xcode
  2. open a specific xcodeproj file
  3. build and debug it
  4. quit xcode
  1. 启动 xcode
  2. 打开一个特定的 xcodeproj 文件
  3. 构建和调试它
  4. 退出 xcode

The following is my first attempt to write AppleScript:

以下是我第一次尝试编写 AppleScript:

tell application "Xcode"
    tell project "iphone_manual_client"
        debug
    end tell
    close project "iphone_manual_client"
end tell

This only works when xcode has this project opened. I would like to have the project to be opened only when it is necessary to do so.

这仅在 xcode 打开此项目时有效。我希望只有在必要时才打开该项目。

Can any AppleScript gurus out there points me to the right direction? Thanks.

任何 AppleScript 专家都可以指出我正确的方向吗?谢谢。

-chuan-

-传-

采纳答案by chuan

I think I managed to solve it. The following is the AppleScript:

我想我设法解决了它。以下是 AppleScript:

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

The path has to be in format of ":" instead of "/". The only problem now is that after the debug console has done its job, AppleScript seems to "hang" as though waiting for something to happen. I need to do more research on AppleScript to know what is wrong with the script.

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

回答by stefanB

I'm not sure about AppleScript but you can compile it from command line, without opening xcode ide, like this:

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

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

Where configuration is obvious option, target is the name in Target list of xcode and the project name at the end.

其中配置是明显的选项,target 是 xcode 的 Target 列表中的名称和最后的项目名称。

回答by cdespinosa

Since debugging can take an arbitrary amount of time, you probably want a "with timeout of seconds" / "end timeout" block around the debug message.

由于调试可能需要任意长的时间,因此您可能需要在调试消息周围使用“超时秒数”/“结束超时”块。

回答by pgb

There's a command line utility called xcodebuild(man page here) which may work better for what you want to accomplish.

有一个名为xcodebuild此处的手册页)的命令行实用程序,它可能更适合您想要完成的任务。