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