Search code examples
c++xcodeheader-filesfile-extensionopenscenegraph

Getting Xcode to recognise C++ header files without the '.h' extension (OpenSceneGraph)


OpenSceneGraph uses header files without the '.h' extension. Is there a way of getting Xcode to recognise the syntax as C++ and therefore allow me to have highlighting and jumping to definitions etc?

Eg: No highlighting:

enter image description here


Solution

  • Yes. Toggle the right panel (the rightmost icon of the "View" section of the toolbar, arrow 1 in the screenshot) with your file selected. Select the document tab in the panel (arrow 2), then find "File Type" under "Identity and Type" (arrow 3). Choose "C++ header" in the dropdown list.

    Graphical version of the previous explanations

    You will need to reopen the file for the syntax coloring to kick in.