如何使用当前的Xcode/Mac OS X v10.8 (Mountain Lion)或更高版本安装命令行构建工具?
与Xcode不同,它没有安装程序,只是一个包。
看起来所有的命令行工具都在包中,在Contents/Developer下面,但是没有设置适当的环境变量来使用它们。
是否有一个脚本,我可以运行,将设置我的环境,以支持从命令行构建?
如何使用当前的Xcode/Mac OS X v10.8 (Mountain Lion)或更高版本安装命令行构建工具?
与Xcode不同,它没有安装程序,只是一个包。
看起来所有的命令行工具都在包中,在Contents/Developer下面,但是没有设置适当的环境变量来使用它们。
是否有一个脚本,我可以运行,将设置我的环境,以支持从命令行构建?
当前回答
如果你在尝试使用命令行工具时查看“控制台”,你会发现实际上有一个到Mountain Lion命令行工具的“非官方”链接!
所以试试吧:
http://adcdownload.apple.com/ios/ios_simulator__resigned/cltools_mountainliondp2_march12.dmg
这是我的控制台日志:
01/04/2012 15:41:54.258 Xcode: [MT] DVTDownloadable: Download failed. Downloadable: {
dependencies = (
);
fileSize = 141452226;
identifier = "Xcode.CLTools.10.8";
name = "Command Line Tools";
source = "http://adcdownload.apple.com/ios/ios_simulator__resigned/cltools_mountainliondp2_march12.dmg";
userInfo = {
ActivationPredicate = "$MAC_OS_X_VERSION >= '10.8.0' && $MAC_OS_X_VERSION < '10.9.0'";
InstallPrefix = "/";
InstalledIfAllSHA1SumsMatch = {
"/usr/bin/clang" = 600c35175775a6002452a88f17e00c570cd2e2d0;
};
Summary = "Before installing, note that from within Terminal you can use the XCRUN tool to launch compilers and other tools embedded within the Xcode application. Use the XCODE-SELECT tool to define which version of Xcode is active. Type \"man xcrun\" from within Terminal to find out more.\n\nDownloading this package will install copies of the core command line tools and system headers into system folders, including the LLVM compiler, linker, and build tools.";
"Xcode.SDKs" = (
);
};
version = "1.1.1";
}. Error: Error Domain=NSCocoaErrorDomain Code=3840 "The data couldn’t be read because it has been corrupted." (Encountered unknown ampersand-escape sequence at line 18) UserInfo=0x401bc8e60 {NSDebugDescription=Encountered unknown ampersand-escape sequence at line 18, kCFPropertyListOldStyleParsingError=The data couldn’t be read because it has been corrupted.}
其他回答
Xcode Command Line Tools can be installed as a side effect of running git --version in Terminal without Git installed. You will be prompted to install the tools as a requirement for running Git. Apple ships a binary of git with the Command Line tools. This is confirmed on the Git for Mac Download page. This seems like a valid option considering that Homebrew requires the Command Line tools to install Git as well according to another SO post. Otherwise, the previous answers are the most direct methods of install the tools.
去developer.apple.com/download/all/(如果你没有登录请登录) 展开所需版本的“命令行工具”的“查看详细信息”工具提示 下载这些命令行工具的.dmg文件 下载.dmg文件后,双击它并安装它
“非官方”链接也可在
http://developer.apple.com/downloads/
403:禁止,除非使用合格的开发人员帐户登录。免费帐户可以访问除预发布软件和完整的操作系统安装之外的所有内容。特别是,与Xcode 4.4发布一致的命令行工具包(“2012年7月”软件包)在7月27日发布,用于Lion和Mountain Lion。
与日志文件、深度链接网页和Xcode首选项窗口不同,这个页面还链接到许多其他有用的下载,免费和付费开发者都可以下载,包括所有从Xcode中解绑定的东西(音频工具、辅助工具等)、OS X内核调试构建,以及Xcode 1.0版本的发布版本。
如果你在尝试使用命令行工具时查看“控制台”,你会发现实际上有一个到Mountain Lion命令行工具的“非官方”链接!
所以试试吧:
http://adcdownload.apple.com/ios/ios_simulator__resigned/cltools_mountainliondp2_march12.dmg
这是我的控制台日志:
01/04/2012 15:41:54.258 Xcode: [MT] DVTDownloadable: Download failed. Downloadable: {
dependencies = (
);
fileSize = 141452226;
identifier = "Xcode.CLTools.10.8";
name = "Command Line Tools";
source = "http://adcdownload.apple.com/ios/ios_simulator__resigned/cltools_mountainliondp2_march12.dmg";
userInfo = {
ActivationPredicate = "$MAC_OS_X_VERSION >= '10.8.0' && $MAC_OS_X_VERSION < '10.9.0'";
InstallPrefix = "/";
InstalledIfAllSHA1SumsMatch = {
"/usr/bin/clang" = 600c35175775a6002452a88f17e00c570cd2e2d0;
};
Summary = "Before installing, note that from within Terminal you can use the XCRUN tool to launch compilers and other tools embedded within the Xcode application. Use the XCODE-SELECT tool to define which version of Xcode is active. Type \"man xcrun\" from within Terminal to find out more.\n\nDownloading this package will install copies of the core command line tools and system headers into system folders, including the LLVM compiler, linker, and build tools.";
"Xcode.SDKs" = (
);
};
version = "1.1.1";
}. Error: Error Domain=NSCocoaErrorDomain Code=3840 "The data couldn’t be read because it has been corrupted." (Encountered unknown ampersand-escape sequence at line 18) UserInfo=0x401bc8e60 {NSDebugDescription=Encountered unknown ampersand-escape sequence at line 18, kCFPropertyListOldStyleParsingError=The data couldn’t be read because it has been corrupted.}
以下是苹果开发者服务器上的命令行工具链接。你可能需要一个苹果开发者(付费/高级)帐户才能访问它们。你可以下载当前的(稳定版和beta版)Xcode工具。(不需要设备验证。在选择命令行工具时,只需确保您的macOS和XCode工具/SDK版本)
Xcode 13 RC
Xcode 13 RC (命令行工具(Xcode 13 RC) - macOS BigSur +)
一旦你在系统中安装了最新的命令行工具,从Xcode菜单中设置它。
▶位置▶命令行工具▶选择合适的命令行工具