如何从终端运行命令行应用程序? [英] How to run command-line application from the terminal?

查看:1441
本文介绍了如何从终端运行命令行应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是最近从Windows转换为Macbook Pro的人.我已经习惯了Xcode.我喜欢的一件事是在终端中运行调试应用程序.当前,我必须按Command + R使其在Xcode中编译和运行.要在终端中运行该应用程序,我必须执行另一个步骤,方法是打开产品"文件夹,右键单击该应用程序,然后单击以外部编辑器打开".然后终端打开并运行程序.

I'm a recent convert from Windows to Macbook Pro. I am getting use to Xcode. One thing that I would enjoy is when running a debug application in the terminal. Currently, I have to press Command+R for it to compile and run in Xcode. To have the application run in the terminal, I have to do an additional step by opening the Products folder, right click the application, then 'Open as Exterior Editor'. Then the terminal opens and runs the program.

我希望通过按Command + R可以自动执行此行为.在我看来,似乎有一种设置可以直接输出.

I would like this behavior to work automatically by pressing Command+R. It seems to me like there would be a setting to direct the output.

有没有什么步骤可以做到这一点?

Are there any steps to accomplish this?

推荐答案

首先,制定一个新方案(或编辑当前方案)并将可执行文件更改为Terminal.app:

First, make a new scheme (or edit the current one) and change the executable to Terminal.app:

然后,在参数"选项卡下,确保将基础扩展打开"设置为您的应用.然后放open -a ${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}

Then, under the "Arguments" tab, make sure "Base Expansions On" is set to your App. Then put open -a ${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}

该命令将扩展为类似open -a /Users/Me/Library/Developer/Xcode/DerivedData/MyProj-abcdefghijklmnopqrrstuvwxyz/Build/Products/Debug-iphonesimulator/Universal.app

open -a是从命令行打开应用程序的方式.

open -a is how you open an App from the command line.

改为使用${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}(请参阅注释).

Use ${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME} instead (see comments).

这篇关于如何从终端运行命令行应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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