How can I use C++ with Objective-C in XCode

Make sure you compile that file as “Objective-C++”.

The simplest way is to rename it as *.mm.

If you don’t want to rename the *.m file,

  1. Select your file.
  2. Open the File Info dialog (Cmd+I)
  3. In File Type, select “sourcecode.cpp.objcpp”

Leave a Comment