Xcode - 使用命令行安装额外的必需组件

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

Xcode - Install additional required components using command line

xcodemacos

提问by x86cam

I recently got a used Mac with Mountain Lion on it. I don't know of the admin password or anything, but I do know how to run a command line.

我最近买了一台带有 Mountain Lion 的二手 Mac。我不知道管理员密码或任何东西,但我知道如何运行命令行。

So here's what I am stuck on: asdf

所以这就是我所坚持的: 自卫队

When I click install, it asks me for my username and password (which I don't know of)

当我点击安装时,它会询问我的用户名和密码(我不知道)

I want to install this via single-user mode (Cmd+S on Startup), which I accepted the license using it.

我想通过单用户模式(启动时 Cmd+S)安装它,我接受了使用它的许可证。

Do you guys know how I could achieve this?

你们知道我怎么能做到这一点吗?

回答by Anshul

At least on XCode 9.2, you could use:

至少在 XCode 9.2 上,您可以使用:

sudo xcodebuild -runFirstLaunch

to accept the agreement and install additional components.

接受协议并安装其他组件。

回答by Shyju s

Resolved this issue using the below commands, it is on OS El Capitan and Xcode beta 7.2

使用以下命令解决了这个问题,它在 OS El Capitan 和 Xcode beta 7.2 上

sudo /Applications/Xcode-beta.app/Contents/Developer/usr/bin/xcodebuild  -license accept
sudo installer -pkg /Applications/Xcode-beta.app/Contents/Resources/Packages/MobileDevice.pkg -target /
sudo installer -pkg /Applications/Xcode-beta.app/Contents/Resources/Packages/MobileDeviceDevelopment.pkg -target /

Change the Xcode-beta.apppath to your own, and you would need sudo(admin) access. Close your Xcode and open again.

Xcode-beta.app路径更改为您自己的路径,您将需要 sudo(admin) 访问权限。关闭您的 Xcode 并再次打开。

回答by typonaut

I know this is a looooooong time after the original post, but just in case anyone else finds this (as I did) while trying to install Xcode 8.2.1 on El Capitan (11.6)…

我知道这是原始帖子之后的很长一段时间,但以防万一其他人在尝试在 El Capitan (11.6) 上安装 Xcode 8.2.1 时发现了这一点(就像我一样)......

I had all the same problems listed here – long delay for lunch, then asking for additional tools to be installed, only to fail. The command line tools install also failed. I tried the various command line solutions listed, but none worked.

我在这里列出了所有相同的问题 - 午餐时间延迟很长,然后要求安装其他工具,但失败了。命令行工具安装也失败。我尝试了列出的各种命令行解决方案,但都没有奏效。

However, upon checking the log I saw that I was getting errors with certificates. On a hunch, I decided to put the system clock back to 20 December 2016 - voila, installs work like magic.

但是,在检查日志时,我发现我收到了证书错误。凭直觉,我决定将系统时钟恢复到 2016 年 12 月 20 日 - 瞧,安装工作就像魔术一样。

Put the clock back to today (30 October 2019) and still seems to work.

将时钟拨回今天(2019 年 10 月 30 日),似乎仍然有效。

回答by Ivo Jansch

The commandline way to install required components is:

安装所需组件的命令行方式是:

/Applications/Xcode.app/Contents/MacOS/Xcode -installComponents

回答by x86cam

Here's what I ended up doing. I went into recovery mode (CMD+R on startup), then to Terminal. I typed in

这就是我最终做的。我进入恢复模式(启动时 CMD+R),然后进入终端。我输入了

resetpassword

which then brought up a dialog of where I can select the user and set the password.

然后打开一个对话框,我可以在其中选择用户并设置密码。

I then set the root password. Now when I can enter an admin password, I type in "root" and the password I set.

然后我设置root密码。现在,当我可以输入管理员密码时,我输入“root”和我设置的密码。

I got Xcode to load finally!

我终于加载了 Xcode!

回答by k06a

Xcode 5.1.1 have a new argument:

Xcode 5.1.1 有一个新参数:

> xcode -installComponents