Xcode - Install additional required components using command line - xcode

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.
So here's what I am stuck on:
When I click install, it asks me for my username and password (which I don't know).
I want to install this via single-user mode (Cmd+S on Startup), which I accepted the license using it.
Do you guys know how I could achieve this?

At least on Xcode 9.2, you could use:
sudo xcodebuild -runFirstLaunch
to accept the agreement and install additional components.

Resolved this issue using the below commands, it is on OS El Capitan and 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.app path to your own, and you would need sudo(admin) access. Close your Xcode and open again.

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 (10.11.6)…
I had all the same problems listed here – long delay for launch, 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.
Put the clock back to today (30 October 2019) and still seems to work.

The commandline way to install required components is:
/Applications/Xcode.app/Contents/MacOS/Xcode -installComponents

Here's what I ended up doing.
I went into recovery mode (CMD+R on startup), then to Terminal. I typed in
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.
I got Xcode to load finally!

Xcode 5.1.1 have a new argument:
> xcode -installComponents

Related

Brew install on Mojave

I did these steps:
Updated to Mojave
Installed Xcode 10 beta3
Ran this command: sudo xcode-select -switch /Applications/Xcode-beta.app/
Now I'm trying to install node8:
brew install node#8
And it gives me this error:
Error: The Command Line Tools header package must be installed on Mojave.
The installer is located at: /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
Still, doing
install -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
does nothing, since there's no such file in my system. Where could I get it?
Go to /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg location and install package manually. And brew will start working.
I want to try and answer this question and also for those that come later that installed Mojave and had an older Xcode version installed. The process is the same minus that if you have Xcode 10, you don't need to install it again from my understanding.
The folder is hidden and was not accessible even with a sudo find command, however, I figured out that copying the absolute path and then pasting it in your browser address bar will give you the download and access to the folder that you need to fix brew install.
I posted a video here- https://youtu.be/GfnhSirTCGM that walks you thru part of my steps above. After you do the SDK headers download, its likely that unless you already are running Xcode 9.4, you will need to visit, https://developer.apple.com/download/more/ and look for Xcode 9.4 to install. Also grab the 10.14 command line tools as well. The lesson that should be learned here is that Apple calls it "Beta" for a reason and if you are a developer that knows the pains of setup, it is a bad idea. I hope that I was helpful! The last thing is, INSTALL XCODE THEN COMMAND LINE TOOLS-IN THAT ORDER OR IT ERRORS OUT! and then we do this all over again. Cheers!
It appears as though Apple has released a patch for the bug and it is available through the system preferences. 14 July 2018
Broken command line tools:
Xcode Location on the Apple developers website:
Location of command line tools:
Do not install Xcode from the Mac App Store because a different version is required!
Command line tools 10.14 update:
As of October 2018, the solution for making brew and brew install succeed is to:
install latest Xcode fom AppStore
run Xcode and install command line tools
add the line before to your profile or somethign similar
export CFLAGS="-I/usr/local/include -L/usr/local/lib -I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include"
No need to download Xcode manually, but you may want to remove the beta version if you installed it.
The magic part is at the end, where xcrun obtains the correct location of the SDK.
In terminal, you should first input the commands below
cd /Library/Developer/CommandLineTools/Packages
open .
you will open the directory on desktop,
then double click the pkg file to install it.

XCode prerequisite version check failed? Unable to package app with Intune Packager

Edit: It appears the latest Release Notes from Apple indicate massive changes with the build system. Currently, Intune's Package Manager hasn't been recently updated, so I don't expect a fix besides downgrading until update.
I just updated XCode and OSX and ran the Intune MAM packager as always, but now instead of succeeding, I get this:
Version of MACOSX is 10.13.5
XCode prerequisite version check failed: failure in executing the xcodebuild command.
Missing prerequisite.
Cause of the error to be provided for investigation:Error Domain=IntuneAppPackager Code=22 "XCode version 5 or greater is required to run this tool." UserInfo={NSLocalizedDescription=XCode version 5 or greater is required to run this tool.}
I already had to re-enable certs to match the profile, but this seems unrelated. I have the latest XCode and the build tools installed via default settings. I googled different parts of this error and nothing came back. This could be InTune's mam packager but the error itself is relatively specific in saying XCode Build tools.
Try this code in your terminal:
xcode-select -p, then check if that path is correct path of your Xcode.
If this doesn't work, try this code:
sudo xcode-select --switch /correct path of the xcode app.
For example:
sudo xcode-select --switch /Applications/Xcode_7.3.1.app/Contents/Developer
This is what I did, and it works!
I have Xcode installed via App Store and came across the same error after switching to a new version of Intune MAM Packager.
sudo xcode-select --switch /Applications/Xcode_7.3.1.app/Contents/Developer
That worked for me

Xcode keeps asking in a loop for authorisation on startup asking "Install additional required components?"

XCode always keeps asking for "install additional required components" in a loop, Has anyone faced this issue.
I am using MaC OX El capitan 10.11.1 and xcode 7.2 beta
Try this from a terminal window:
git status
or
sudo git status
If it asks you do install additional Xcode components, do so. It may ask you read and agree to an End User License Agreement (which I think you must do to proceed).

How to accept Xcode license?

I've been searching the web to look for how to accept Xcode in order to use Xcode to recompile a MATLAB Windows file for a MAC but I did not find any relevant answer.
The error message I get in MATLAB is :
Xcode is installed, but its license has not been accepted. Run Xcode
and accept its license agreement.
I have accept its license through the terminal command sudo xcodebuild -license then -q then agree but I still get the same error message. I have also accepted the license when first opening the application.
Do someone know how to solve this problem?
Xcode : version 6.4 and Matlab R2015a
You can use the following command to directly accept the license:
sudo xcodebuild -license accept
If you are using the command line then go through the entire license by entering space until you get to the end where you will be presented with:
By typing 'agree' you are agreeing to the terms of the software license agreements. Type 'print' to print them or anything else to cancel, [agree, print, cancel]
type "agree" and return
Alternatively just launch Xcode by double clicking it's icon and when presented with the license agreement accept it.
Updated for new information:
It seems this may be a MATLAB issue. What version of Xcode are you running? Check with MATLAB to see if that is a supported version.
Simply type the sudo xcodebuild -license into the terminal after press q for quite
then type agree
Note: Xcode name should be Xocde not like that Xcode 8.2,etc.,
If you have only the Command Line Tools installed (and you don't want the full Xcode), none of the above works. From my saver here, run the following to trick mex into seeing an accepted license (no sudo needed).
Here I use the current version 13.0 at the time of writing, to be adapted.
defaults write com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense 13.0
You can also try enabling the command line tools, which should help prevent the license acceptance issue:
# Install Command Line Tools
xcode-select --install
# Enable command line tools
sudo xcode-select --switch /Library/Developer/CommandLineTools
Source: https://github.com/nodejs/node-gyp/issues/569
What worked for me was deleting the file: Library/Preferences/com.apple.dt.Xcode.plist and then running 'sudo xcodebuild -license accept' in the terminal.
The first Xcode Licence I agreed to was a beta license. Therefore somehow the entries in this file were still named ...beta... what seems to have caused the error. By running 'sudo xcodebuild -license accept' a new file is created that is compatible with Matlab (provided ur not using a beta Xcode Version).
I also downloaded the latest Version of the Command Line Tools but I don't know if that would have been necessary.
Hope I could help.
This is from 2021, using Mac Big Sur version 11.0.1 with Xcode-beta
My problem is that Macports install requires Agree to Xcode license in Terminal: sudo xcodebuild -license but that command returned only xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance.
I found a stack overflow issue that mentioned how to reset the xcode-select.
which in my case is sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer. Then I used sudo xcodebuild -license, scrolled through the license and accepted it. (Via the application, I never had an option to accept.)
the other stack flow issue that helped me is xcode-select active developer directory error
FYI - If you have installed the beta version at some point, deleted it, and then installed the regular version of Xcode, the license file will still be associated with beta version. This is what was happening to me, as I continued to get the warning about not having accepted the license. To fix this issue, you need to delete the Xcode license file and then run the above command in terminal.
Navigate to /Library/Preferences/
Delete the file com.app.dt.Xcode.plist
Then in terminal sudo xcodebuild -license accept
Then in Matlab mex -setup
This worked for me! Note that this method of deleting the plist file was provided to me by the folks at Mathworks support. There had been existing issues related to beta installs of Xcode.

Failed to install command line tools on OSX Mavericks

I tried to install the command line tools on Mavericks following the steps in this very useful post
> xcode-select --install
but after a few short seconds I get the message
This seems wrong. Does anyone know how to solve this problem?
Whenever I navigate to the page that #Nikos M. is suggesting
I get this message
I followed #Rich's suggestion and I was able to download the package and install it which I wasn't able to do before, but I've found that I still don't have access to a lot of the commands that I should like arp or diskutil just to name two that I've encountered recently.
Install them from here. You must be a registered developer.
Other solution is: in xcode click Xcode>Open Developer Tool>More Developer Tools
This should then take you to a link which will require a developer Apple ID sign in. From there, you'll be redirected after authenticating to https://developer.apple.com/download/more/ where you can manually download and install the Command Line Tools.
The tools are still free, but xcode-select --install is no longer supported.
To install the latest command-line developer tools from https://developer.apple.com,
Applications -> App Store -> Search -> XCode -> Install ... install
XCode if you don't have it.
Open XCode and close any pop-ups
Go to the Xcode menu > Open Developer Tool > More Developer Tools... this opens the correct website.
Find the newest version, download the dmg and install the package. The filename you're looking for is similar to "Command Line Tools (OS X 10.9).pkg"
I had this problem for months and finally found the solution.
The problem was: I had installed it before and removed it manually.
(I had problems with the bundled git. It was not the smartest move to do this.)
What i didn't remove were the files
/var/db/receipts/com.apple.pkg.CLTools_Executables.bom
/var/db/receipts/com.apple.pkg.CLTools_Executables.plist
Delete them, run xcode-select --install -> no error anymore
At least it worked for me. Hope it is helpful for somebody.
I get that "Your Session has Expired" message when I try to download from within the Chrome browser. If I navigate to the site with Safari and sign in with my developer credentials then the Command Line Tools dmg downloads without a problem. I do not have a paid developer account either, btw.
You can download your Command Line Tools from daw.apple.com, but try it from Safari instead of Chrome.
I tried it with Chrome for a few hours and apple would not recognize my id/password (it is the same as your AppleID). It required me to change my password after each third try, which was challenging because it would not let you use any password you've used in the last three years.
Signing in via Safari gave me no problems.
The file you are going to look for is Command Line Tools (OS X Mavericks) for Xcode - Late October
If your terminal still says you need to install command line tools, it may be an issue with gcc-4.2. I was able to confirm that was the issue by following my terminal message after I ran "bundle install" on my rails app. If this is your issue, you will do the following follow Housen's solution here. Best of luck
I spent the day trying to solve this problem. I believe the error messages are just confused about installing Xcode. The real problem I had was a need to update gcc compiler. This happened to me because I skipped Mountain Lion, where that occurred. This blog post was very helpful.
I solved it by open XCode UI, then adding my apple account
Xcode -> Preference -> Add my APPLE ID account
Then repeat the xcode-select --install
Try to install the command line tools following
Error Message "Xcode alone is not sufficient on Sierra"
brew seems checks if the command line tools installed in this path:
/Library/Developer/CommandLineTools
My case is: I tried to install brew on my new mac. After I installed Xcode, there was nothing in the above path but the command line tools were somehow installed to another location. (xcode-select -p tell me it was /Applications/Xcode.app/Contents/Developer)
The way in stackoverflow can install the command line tools to
/Library/Developer/CommandLineTools
Now I got brew working. But I am not sure if it is the best solution as there should be two copies of command line tools on my machine using this method.

Resources