How to accept Xcode license?

I want to install a C based toolbox on MATLAB software. To do this, I need to install the GCC compiler. I think I have done that already. And I have Xcode too. To setup the toolbox, I need to write mex -setup; in the MATLAB command window. I've got the following warning and don't know how to solve it:

Warning: Xcode is installed, but its license has not been accepted. Run Xcode and accept its license agreement. Error using mex
No supported compiler or SDK was found. For options, visit http://www.mathworks.com/support/compilers/R2014a/maci64.

4,098 7 7 gold badges 36 36 silver badges 49 49 bronze badges asked Mar 2, 2015 at 16:21 798 2 2 gold badges 7 7 silver badges 16 16 bronze badges What version of Xcode is in play here? What OS X build? Are both from the Mac App Store? Commented Mar 3, 2015 at 0:56 Commented Feb 2, 2016 at 13:03

6 Answers 6

sudo xcodebuild -license 

Which should view/accept it on behalf of all accounts on that particular Mac.

In recent Xcode versions you are able to accept it in one step:

sudo xcodebuild -license accept 
59.4k 10 10 gold badges 111 111 silver badges 134 134 bronze badges answered Oct 28, 2015 at 12:49 20.8k 9 9 gold badges 71 71 silver badges 114 114 bronze badges

Running xcodebuild -license from the command line (without sudo) yields the error Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo. , so I think the sudo is needed.

Commented Dec 23, 2015 at 0:24 In recent XCode versions you can also use sudo xcodebuild -license accept to avoid manual input. Commented Feb 2, 2016 at 13:04

@OhadSchneider Thanks for the tip. I wonder exactly what purpose this serves, legally.. Not that people actually read the ToS, but XCode having something where you can set up a script to blindly accept a legal agreement makes it feel like it'd be hard to actually enforce the terms in court.

Commented Mar 25, 2016 at 12:57

So the answer to the above thing since there's a stack overflow bug that prevents me from editing it is that Xcode -license accept doesn't send out any network packets but instead modifies a file on disk. You may need to go to developer.apple.com/account and accept it there instead. Then you'll need to restart Xcode since it can't figure this side channel solution. This bug-filled dance would be hilarious if it didn't take me over an hour to figure it out.

Commented Oct 11, 2016 at 21:39 @Electricman this should be the accepted answer Commented Jun 25, 2018 at 12:14

You need to start/open Xcode once to accept the license agreement. Easiest way to run the application is by clicking on the Spotlight icon on top right and just type its name.

answered Mar 2, 2015 at 16:25 nohillside ♦ nohillside 103k 42 42 gold badges 219 219 silver badges 271 271 bronze badges I've opened it already. But I didn't ask me anything. :( I also, created a project too. @patrix Commented Mar 2, 2015 at 16:30

@Electricman If you open terminal and type these two commands what are your results? sudo xcode-select -r and sudo xcode-select --install (and if it says you should run Software Update, check there are no Xcode pending updates with sudo softwareupdate -l

Commented Mar 2, 2015 at 16:41

I wrote sudo xcode-select -r and sudo xcode-select --install and a window has been appeared saying the xcode selected command requires the command line developer tools. would u like to install the tools now with three button including, not now, get xcode and install. So, I selected install Xcode and accepted the licence, and then another boxed opened finding software that says cant install the software be it is not currently available from the software update server. what should I do? @bmike Also, sudo softwareupdate -l shows nothing about xcode needs for updates

Commented Mar 2, 2015 at 16:52

@Electricman Odd - is this computer managed by a corporate IT department? Is your log in user an Admin user? If so, I'd make a new admin test account and re-run the Xcode commands - it could be simply your user or permissions are wonky. Hard to tell without sitting at that computer. The commands should get you all the permissions you need. Worst case, install all the updates and try again with the new user.

Commented Mar 2, 2015 at 17:04

It is a Admin user. I made a new admin account but got a different error too. very bad situation @bmike