从终端窗口运行 Xcode 工具

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1930092/
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 19:00:59  来源:igfitidea点击:

Run Xcode tools from the Terminal window

xcodeunixcommand-lineterminal

提问by durcicko

This is something really simple, but I can't seem to find the answer anywhere, and I'm new to both Mac and UNIX, which doesn't help.

这真的很简单,但我似乎无法在任何地方找到答案,而且我对 Mac 和 UNIX 都不熟悉,这无济于事。

I've installed Xcode on my mac, along with the iPhone SDK 3.2. I'm trying to run Xcode command utilities that came with the SDK from the unix terminal, but I don't know how to update the paths so that the system knows where to find them. Here is what I do.

我已经在我的 Mac 上安装了 Xcode,以及 iPhone SDK 3.2。我正在尝试从 unix 终端运行 SDK 附带的 Xcode 命令实用程序,但我不知道如何更新路径以便系统知道在哪里可以找到它们。这就是我所做的。

  1. I launch the Terminal application
  2. I want to run 'xcrun', so I just type 'xcrun'
  3. I get an error saying '-bash: xcrun: command not found'
  4. I have xcrun installed under /Developer/usr/bin
  1. 我启动终端应用程序
  2. 我想运行“xcrun”,所以我只输入“xcrun”
  3. 我收到一条错误消息“-bash: xcrun: command not found”
  4. 我在 /Developer/usr/bin 下安装了 xcrun

Is there some sort of PATHS environment variable that I need to permanently update? Or perhaps Xcode comes with its own Terminal application with those new paths already baked in? Finally, what's the difference between sh and bash?

是否有某种 PATHS 环境变量需要永久更新?或者,也许 Xcode 带有自己的终端应用程序,其中已经包含了这些新路径?最后,sh 和 bash 有什么区别?

Thanks for the help!

谢谢您的帮助!

采纳答案by mipadi

I'm using Snow Leopard + Xcode, and xcodebuildand xcrunare both present at /usr/bin. Regardless, they shouldbe present at /Developer/usr/bin-- you just have to make sure that path is in your $PATHvariable. You can set it in your shell configuration file (~/.bashrcfor bash) like so:

我使用的是雪豹+ Xcode中,并xcodebuildxcrun同时存在的/usr/bin。无论如何,它们应该出现在/Developer/usr/bin——你只需要确保路径在你的$PATH变量中。您可以在 shell 配置文件 ( ~/.bashrcfor bash) 中设置它,如下所示:

export PATH="/Developer/usr/bin:${PATH}"

As for the difference between shand bash, bashsupports some extensions and other features not found in the more primitive sh; however, on Mac OS X, shand bashare the same program (this is typical on many Unix and Linux systems nowadays). However, when bashis invoked as sh(that is, you call /bin/shfrom the command line, rather than /bin/bash), bashwill try to act like the more "traditional" shprogram.

至于sh和和的区别bashbash支持一些扩展和其他更原始的没有的特性sh然而,在Mac OS X,sh以及bash同属于一个程序(这是许多Unix和Linux系统的典型时下)。但是, whenbash被调用为sh(即,您/bin/sh从命令行调用,而不是/bin/bash),bash将尝试像更“传统”的sh程序一样工作。