Xcode .m vs. .mm Xcode .m vs. .mm xcode xcode

Xcode .m vs. .mm


.mm extension stands for Objective-C++, when compiler can process C++ classes.But when using .m extension it will be able to compile only C code, without C++ classes.


Both .m and .mm are class file extensions of source code for Mac-based applications. .m files can contain both Objective-C and Objective-C++ classes. To avoid conflicts between the two in mixed-use scenarios there's the convention to rename all Objective-C++ class files to .mm. This helps compilers to distinguish.

So in a project which uses both Objective-C and Objective-C++ you will see:

  • .m files containing Objective-C
  • .mm files containing Objective-C++