By default, Xcode creates both an .h and .m file when requesting a new ObjC class. Everything works fine until you need to reference any C ++ file elsewhere in your project and do not run it in a .h or .m file.
At that moment, when the ObjC compiler is completely confused and throwing mountains of parsing errors, and you, the user (that is: me), are even more confused until it hits me: of course, I have to make this file instead this objc ++ file.
Possible options:
- tell Xcode that this particular file, even if it is a .m file, is really an ObjC ++ file or
- rename this file to .mm.
The first option is not very pleasant for me, because this file is really ObjC ++, regardless of what, according to the project, is.
The second option doesnโt work, because it twists the Git repository, which then forgets that another .m file was used earlier, which is really the history of this โnewโ .mm file.
So, from now on, I decided to always rename any .m file that Xcode creates for me .mm first, after creating, so that I don't lose the story.
So far, it worked well for me, but I have this slight concern in my head that there might be some kind of angular case when I really want to have an ObjC file, not an ObjC ++ file.
What would these corner cases be? Does anyone know of any ObjC ++ file that happens to NOT contain a C ++ link, but somehow strangled the ObjC compiler, simply thanks to the .mm file?
And if there are no flaws, why not just give up .m forever and stick with .mm instead?