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.


6 Answers 6


In Terminal:

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
  • 2
    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.
    – D.W.
    Commented Dec 23, 2015 at 0:24
  • 7
    In recent XCode versions you can also use sudo xcodebuild -license accept to avoid manual input. Commented Feb 2, 2016 at 13:04
  • 2
    @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
  • 1
    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
    – rexford
    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.

  • 2
    I've opened it already. But I didn't ask me anything. :( I also, created a project too. @patrix
    – SAH
    Commented Mar 2, 2015 at 16:30
  • 1
    @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
    – bmike
    Commented Mar 2, 2015 at 16:41
  • 1
    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
    – SAH
    Commented Mar 2, 2015 at 16:52
  • 1
    @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.
    – bmike
    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
    – SAH
    Commented Mar 2, 2015 at 17:27

You can also do this from the command line sudo xcrun cc


If you have only the Command Line Tools installed (and you don't want the full Xcode), the solution is a bit trickier. From my saver here, run the following (no sudo needed) and the mex -setup command will work like a charm. 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
  • to get the version I had to do this: stackoverflow.com/a/42144725/764365
    – Jimbo
    Commented Nov 26, 2022 at 5:33
  • @Jimbo It might be that the version is the SDK version instead of the version you extracted. I'm not sure at all, but in my case, the pkgutil command you mentioned to gives me '14.1.xxxxx', but the highest version of SDKs I have is 13.0 (in /Library/Developer/CommandLineTools/SDKs)... Not sure what IDEXcodeVersionForAgreedToGMLicense exactly refers to and whether it really matters to trick mex.
    – jmon12
    Commented Nov 27, 2022 at 15:40

If you don't have XCode installed, you can download it from Apple Developer or the App Store.

I had to do the Clover-Space, type xcode (Which pulled up XCode-Beta), and press Clover-Enter to open the file location. I found that my XCode was still in the "Downloads" folder.

So I drag/dropped it onto the Applications folder, then I ran: Download Xcode or move it to your Applications folder. Then, open terminal and run both of these commands. One after the other.

sudo xcode-select -s /Applications/Xcode-Beta.app/Contents/Developer

sudo xcodebuild -license

Then space-down to the bottom and type "agree"

  • bret7600, if you want to answer with your answer, create a new answer. You completely removed the whole point of my answer. If you want to edit somebody's answer, add clarity. Don't rewrite the whole thing.
    – Suamere
    Commented Oct 25, 2016 at 13:11
  • I'm assuming [Apple Developer][1] is supposed to be a link?
    – tubedogg
    Commented Oct 25, 2016 at 21:21
  • @tubedogg Thanks, must have gotten cut off in the edit.
    – Suamere
    Commented Oct 25, 2016 at 21:28

You must accept the XCode license. If you don't have XCode installed / don't need the application, you can instead just install the developer tools, which will also complete the license agreement:

# 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .