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

1 Answer 1

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.

4
  • 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, 2013 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, 2013 at 21:37
  • What about for files in library/system headers that are not part of any project?
    – OrangeDog
    Apr 15, 2015 at 10:27
  • @OrangeDog, can't help you with that one.
    – zneak
    Apr 15, 2015 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.