Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Syntax Highlighting for GLSL in XCode 6

I'm wondering how I can change the default syntax highlighting for file extensions in XCode as there are some extensions I use for coding GLSL shaders which aren't recognised by XCode.


In the Syntax Highlighting menu there is an option to change the scheme, and there is a GLSL scheme I would like to use. There is also the option 'Default for File Type'. I would like to be able to set this default for my file types, but unfortunately I can't figure out how. Any advice would be appreciated!


Cheers,


Lou.

iMac, OS X Yosemite (10.10.4), XCode 6.4

Posted on Jul 27, 2015 5:07 AM

Reply
7 replies

Mar 3, 2017 3:10 PM in response to DrUmanBays

It's annoyingly non-obvious, but easy once you know what to do. Follow this stackexchange thread, and use UTI org.khronos.glsl-source to identify the type.


http://stackoverflow.com/questions/41961953/adding-syntax-coloring-to-xcode-for- unknown-file-extension-such-as-tcl


Don't bother trying to edit Standard file types.pbfilespec . It annoyingly looks like it should work by simply adding your own extension to the list, but it doesn't. ***, Apple?...

Jul 29, 2015 3:23 AM in response to etresoft

Thanks for this. You're right, that's a lot of effort for something which should be so simple!

The thing is, there is already syntax highlighting for GLSL, all I want is to make XCode recognise my custom file extensions. Shouldn't be that hard, right?


Anyway, I'll have a look at your code and see if I can use something from it, thanks!

Jul 29, 2015 3:25 AM in response to Mark Szymczyk

Yes, I suppose I could use the .glsl file extension, but it means rewriting my compilation code, at least in part, and frankly I can't be bothered...


Thing is, I use different extensions for different stages of the pipeline, .vert for vertex shaders, .frag for fragment, and so on. I'd just like XCode to recognise these as GLSL by default. It's not the end of the world if it doesn't, but it seems a shame there is no easy way to do this.

Jul 29, 2015 5:50 AM in response to DrUmanBays

Any reason why you don't incorporate the “vert”, “frag”, etc functional name components into the file basename (foo_vert.glsl), and use the proper Xcode expected extensions? That way, you don't find yourself painted into a corner, and have to expend otherwise productive coding time, looking for a different shade (syntax color scheme) of paint.

Jul 29, 2015 6:19 AM in response to VikingOSX

Yes, I suppose that's probably a better way of doing it than my method. Basically, my compile function takes a file name, e.g. 'flatShader' and looks for files with the allowed extensions (.vert, .tcnt, .tevl, .geom, .frag), compiles them based on the extension and then links the lot.


But you're right, I should just re-write it to look for _vert.glsl etc. at the end of the filename, and compile based on that. However, XCode already seems to support picking GLSL syntax highlighting for .vert, .geom and .frag (or .vs, .gs and .fs as used by the Shader Builder in the graphics tools) extensions - perhaps I just need to find out the right extensions for my tessellation control and evaluation shader stages?

Syntax Highlighting for GLSL in XCode 6

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.