Xcode命令行工具 - 如何在终端运行? [英] Xcode command line tool - how to run in terminal?

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

问题描述

当你在Xcode中创建一个命令行工具项目时,你在Main.m中得到这个:

When you create a Command Line Tool project in Xcode you get this, in main.m:

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{

    @autoreleasepool {

        // insert code here...
        NSLog(@"Hello, World!");


    }
    return 0;
}

我可以从Xcode运行。但我想编译它,使我可以从终端运行它。

I can run this from Xcode. But I want to compile it so that I can run it from Terminal. What are the steps?

推荐答案

假设您的可执行文件命名为my_program,它在/ foo / bar / Debug 目录:

Assuming your executable is named "my_program", and it's in the "/foo/bar/Debug" directory:

cd /foo/bar
./my_program

如果您不确定如何找到程序文件本身,可以右键单击它(即:产品)和 Finder,如下面的截图所示:

If you aren't sure how to find the program file itself, you can right-click it (i.e.: the "product") and "Show in Finder" as shown in this screenshot:

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

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