20

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

wonea
  • 4,783
  • 17
  • 86
  • 139
sarah
  • 201
  • 1
  • 2
  • 4
  • 2
    So I assume you are running that from the command line? If so start the Xcode app and accept the license. – trojanfoe Jul 13 '15 at 13:47

8 Answers8

23

You can use the following command to directly accept the license:

sudo xcodebuild -license accept
Ronan Boiteau
  • 9,608
  • 6
  • 34
  • 56
  • 5
    I get `xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance` when running this – Ben Apr 30 '19 at 20:29
  • 1
    Try setting it: `sudo xcode-select -s /Applications/Xcode.app/Contents/Developer` – legends2k Aug 27 '20 at 04:04
4

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.

zaph
  • 111,848
  • 21
  • 189
  • 228
4

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.,

cmcginty
  • 113,384
  • 42
  • 163
  • 163
Ekambaram E
  • 1,184
  • 1
  • 11
  • 9
3

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
jmon12
  • 1,090
  • 8
  • 17
  • This worked for me, thanks for posting! I just want to clarify for future readers that the version number is the version of *Xcode*, not the license or anything else. But I don't think the version matters to Matlab. – mhopeng Dec 23 '22 at 00:05
1

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

Jake
  • 990
  • 1
  • 10
  • 17
1

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.

Michael
  • 15
  • 4
0

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.

Beyazid
  • 1,795
  • 1
  • 15
  • 28
0

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

Ruth Berge
  • 21
  • 4