I have been able to hit a breakpoint in my mex code, within the Xcode IDE, by doing the following steps:
- Building the mex file from within Xcode
- Starting MATLAB in a terminal window by calling "matlab -nojvm"
- Attaching Xcode to the MATLAB process
- Putting a breakpoint in my mex function
- Calling my mex function from MATLAB
This isn't ideal because I had to compile the mex library/application from within Xcode, rather than the normal way I do it, which is just on the MATLAB command line with my own special script. I think there must be a command line option for the compiler which I'm not using in my script, but the Xcode project is. I use only the -g option. The Xcode project uses:
-x c++ -arch x86_64 -fmessage-length=0 -fdiagnostics-show-note-include-stack
-fmacro-backtrace-limit=0 -std=gnu++11 -stdlib=libc++ -fmodules -gmodules
-fmodules-prune-interval=86400 -fmodules-prune-after=345600
-fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module
-Werror=non-modular-include-in-framework-module -Wno-trigraphs
-fpascal-strings -O0 -fno-common -Wno-missing-field-initializers
-Wno-missing-prototypes -Werror=return-type -Wunreachable-code
-Werror=deprecated-objc-isa-usage -Werror=objc-root-class
-Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors
-Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label
-Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body
-Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants
-Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion
-Wenum-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -DMATLAB_MEX_FILE -D_MATLAB_=806
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
-fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof
-mmacosx-version-min=10.11 -g -fvisibility-inlines-hidden -Wno-sign-conversion