9

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

bjz
  • 941
  • 1
  • 8
  • 26

1 Answers1

9

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.

zneak
  • 124,558
  • 39
  • 238
  • 307
  • Is there a way to make Xcode do this automatically for certain extension so that it doesn't have to be repeated manually for each such file? – Vishal Jul 19 '13 at 18:35
  • I'm on a Windows machine right now so I can't check, but while I know for sure you can't do that for files without extensions, I'm pretty sure you can do that for specific extensions from one of the tabs in the project settings. Click your project in the file explorer and check the build rules. – zneak Jul 19 '13 at 21:37
  • What about for files in library/system headers that are not part of any project? – OrangeDog Apr 15 '15 at 10:27
  • @OrangeDog, can't help you with that one. – zneak Apr 15 '15 at 16:19