Skip to content

Instantly share code, notes, and snippets.

@martinandersen
Last active October 25, 2022 02:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinandersen/1fea529ec04885c63477ccb944394494 to your computer and use it in GitHub Desktop.
Save martinandersen/1fea529ec04885c63477ccb944394494 to your computer and use it in GitHub Desktop.
How to build MEX files with MATLAB on macOS without installing Xcode

Building MEX files with MATLAB on macOS without installing Xcode

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment