XCode 4.3 命令行工具

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

XCode 4.3 Command Line Tools

xcodecommand-linedocumentation

提问by Alerty

Apple has recently released Command Line Tools:

苹果最近发布了命令行工具

  1. What are the tools provided in the Command Line Tools package?

  2. Is there some sort of documentation other than man pages?

  1. 命令行工具包中提供了哪些工具?

  2. 除了手册页之外,是否还有某种文档?

Please note that I have installed these tools by adding the specific component in Xcode. Also, this is not about a Xcode project, but a packagereleased by Apple on February 16, 2012!

请注意,我已经通过在 Xcode 中添加特定组件来安装这些工具。另外,这不是关于 Xcode 项目,而是Apple 于 2012 年 2 月 16 日发布的

采纳答案by Sam Morris

Open the command line tools DMG and you'll find a meta-package, which you can extract with the command pkgutil --expand 'Command Line Tools.mpkg' metapackage. Open the metapackage/Distributionfile that was just extracted in a text editor to see the packages that comprise the meta-package:

打开命令行工具 DMG,你会发现一个元包,你可以用命令提取它pkgutil --expand 'Command Line Tools.mpkg' metapackagemetapackage/Distribution在文本编辑器中打开刚刚提取的文件以查看包含元包的包:

com.apple.pkg.DevSDK
com.apple.pkg.X11SDK
com.apple.pkg.QuickTimeSDK
com.apple.pkg.OpenGLSDK
com.apple.pkg.WebKitSDK
com.apple.pkg.FireWireSDK
com.apple.pkg.BluetoothSDK
com.apple.pkg.CoreAudioSDK
com.apple.pkg.JavaSDK
com.apple.pkg.clang
com.apple.pkg.llvm-gcc4.2
com.apple.pkg.X11Documentation
com.apple.pkg.DeveloperToolsCLI

The corresponding package files are found in a hidden Packagesdirectory alongside the metapackage. Their contents can be listed with pkgutil --payload-files.

相应的包文件Packages位于元包旁边的隐藏目录中。它们的内容可以用 列出pkgutil --payload-files

If you have a file on disk, and want to know which package it came from:

如果您在磁盘上有一个文件,并且想知道它来自哪个包:

$ pkgutil --file-info /usr/bin/clang
volume: /
path: /usr/bin/clang

pkgid: com.apple.pkg.clang
pkg-version: 4.3.0.0.1.1249367152
install-time: 1342021874
uid: 0
gid: 0
mode: 755


Now, some bonus information that will be useful if you ever want to removethe command-line tools. Apple, in their infinite wisdom, decline to provide a tool to do so, but we can obtain the information we need by using pkgutilto display information about installed packages.

现在,如果您想删除命令行工具,一些额外的信息将非常有用。Apple 以其无穷的智慧拒绝提供一个工具来这样做,但我们可以通过使用pkgutil来显示有关已安装包的信息来获取我们需要的信息。

Firstly, pkgutil --pkgswill list all installed packages. Compare the output of the list of packages above.

首先,pkgutil --pkgs将列出所有已安装的软件包。比较上面包列表的输出。

pkgutil --infowill display information about an installed package; for example:

pkgutil --info将显示有关已安装软件包的信息;例如:

$ pkgutil --info com.apple.pkg.clang
package-id: com.apple.pkg.clang
version: 4.3.0.0.1.1249367152
volume: /
location: /
install-time: 1342021874
groups: com.apple.FindSystemFiles.pkg-group com.apple.DevToolsBoth.pkg-group com.apple.DevToolsNonRelocatableShared.pkg-group

pkgutil --fileswill display the contents of an installed package, relative to the volumeand locationfields given by pkgutil --info. Because the absolute paths are not used, you can't simply pipe the output of this command to xargs rm -fto remove a package's files; you'll have to fix up the paths yourself, perhaps with something like pkgutil --files com.example.pkgname | while read line; do rm -f "/install_location/$line"; done.

pkgutil --files将显示已安装包的内容,相对于由给出的volumelocation字段pkgutil --info。因为没有使用绝对路径,所以不能简单地将此命令的输出通过管道传输xargs rm -f到删除包的文件;您必须自己修复路径,也许使用类似pkgutil --files com.example.pkgname | while read line; do rm -f "/install_location/$line"; done.

Once a package's files are removed, pkgutil --forgetshould be run to remove information about the installed package from the package database.

删除包的文件后,pkgutil --forget应运行以从包数据库中删除有关已安装包的信息。

It shouldgo without saying that you should be very careful if you try this: you're one typo away from screwing your system up so badly that you'll have to reinstall it, to say nothing of your precious data!

应该不用说,如果你尝试这个你应该非常小心:你是一个错字远离拧你的系统如此糟糕,你必须重新安装它,更不用说你的宝贵数据的说!

pkgutilhas some other useful options for verifying that a package's files are all present, and for restoring their permissions; see its manual pagefor the details.

pkgutil有一些其他有用的选项来验证包的文件是否都存在,以及恢复它们的权限;有关详细信息,请参阅其手册页

In general, this will work for any package, however note that some packages can have embedded scripts that get run when the package is installed; obviously, merely removing the package's files won't remove all traces of the package from your system. You'll have to extract the package's contents and read the script source code, and then decide how best to undo the effects of the script yourself.

通常,这适用于任何包,但请注意,某些包可能具有在安装包时运行的嵌入式脚本;显然,仅仅删除包的文件不会从系统中删除包的所有痕迹。您必须提取包的内容并阅读脚本源代码,然后自己决定如何最好地撤消脚本的影响。

回答by S2VpdGgA

I had a similar problem: I couldn't run "make" after upgrading to Xcode 4.3. To fix it, I just set my PATH variable to include:

我有一个类似的问题:升级到 Xcode 4.3 后我无法运行“make”。为了修复它,我只是将我的 PATH 变量设置为包括:

/Applications/Xcode.app/Contents/Developer/usr/bin
/Applications/Xcode.app/Contents/Developer/Tools

Once I had that set up, replacing my old PATH entries referring to /Developer, I could run a "make" from the command line again.

一旦我进行了设置,替换了我引用 /Developer 的旧 PATH 条目,我就可以再次从命令行运行“make”。