Getting Matlab 2012b to work with XCode 5 (OS X 10.9 Maverick)

Mathworks haven’t issued a patch for 2012b and OS X 10.9 so I ran the 10.9 patch (from¬†http://www.mathworks.com/matlabcentral/answers/94092) and ran

mex -setup

I then modified the mexopts.sh file (mex -setup tells you where this is, on my system its

edit ~/.matlab/R2012b/mexopts.sh

In the section called

#PATCH: MacOSX10.8

remove the version numbers from CC and CXX and correct the SDKROOT. I also changed the deployment target to 10.9

#PATCH: MacOSX10.8

CC='llvm-gcc'
CXX='llvm-g++
SDKROOT='/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/'
MACOSX_DEPLOYMENT_TARGET='10.9'

After a restart, mex worked fine.