MATLAB requires Xcode to build MEX files on macOS: if only the Command Line Tools are available, MATLAB complains that "Xcode is installed, but its license has not been accepted."
To build MEX files with only the Command Line Tools installed, open Terminal and execute the following command to create a property list:
defaults write com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense 12.0
(Replace 12.0 by the current version of Xcode.) You should now be able to use mex
and mex -setup
without MATLAB issuing Xcode-related complaints. Alternatively, use PlistBuddy
:
/usr/libexec/PlistBuddy -c 'Add :IDEXcodeVersionForAgreedToGMLicense string 12.0' ~/Library/Preferences/com.apple.dt.Xcode.plist