如何构建 &使用 Applescript 运行 Xcode? [英] How to build & run Xcode with Applescript?

查看:41
本文介绍了如何构建 &使用 Applescript 运行 Xcode?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在另一个编辑器(即 Vim)中模拟 Xcode 的 ⌘-R 击键;我想我可以用一些 shell 脚本来做到这一点 &applescript,但它似乎无法正常工作:

I'm trying to emulate Xcode's ⌘-R keystroke in another editor (namely, Vim); I thought I would be able to do this with some shell scripting & applescript, but it doesn't seem to be working correctly:

open -a Xcode "MyProj.xcodeproj"
osascript -e 'tell app "Xcode"' -e 'build' -e 'launch' -e 'end tell'

这样做的问题是无论 Xcode 是否报告错误,它都会启动应用程序.有什么办法可以解决这个问题吗?

The problem with this is it launches the app regardless of whether Xcode reports errors. Is there any way to fix this?

推荐答案

我使用:

osascript -e 'tell application "Xcode"
    activate

    set targetProject to active workspace document
    if (build targetProject) is equal to "Build succeeded" then
        launch targetProject
    end if
end tell'

当然,项目必须已经在 Xcode 中打开才能工作.(我宁愿不将当前项目硬编码到我的脚本中)

Of course, the project has to already be open in Xcode for this to work. (I'd rather not hard code the current project into my script)

这篇关于如何构建 &使用 Applescript 运行 Xcode?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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