Adding syntax coloring to Xcode for unknown file extension such as ".tcl"
Asked Answered
E

1

3

I want to ask a question about Xcode syntax coloring (highlighting). I am working with files all the time .tcl files all the time and Xcode does not know extension and as default it opens them with "Generic" syntax coloring option. In this situation, "AppleScript" in the syntax coloring section will be very nice for files with .tcl extension to see all the colors for different things in the code. So, how can i add a new option for .tcl files or how can i change the "Generic" one which appears when i open a .tcl file in Xcode ? Is there any way to do it as defaultly open the .tcl files with "AppleScript" syntax coloring ?

Thank you for your answers...

Ethiopic answered 31/1, 2017 at 16:0 Comment(0)
H
5

Yes there is.

What you need to do is create a new macOS project in Xcode (I will call it SyntaxHighlighting:

enter image description here

Then go to Info -> Exported UTIs:

enter image description here

Click the plus button. Set the Identifier to something like com.umutkeskin.tcl-source.

The Conforms To section tells you what highlighting the UTI will use. You can see the full list of System-defined uniform type identifiers here. The one you want is com.apple.applescript.text.

Set the Extension to tcl. This sets the file extension that this UTI will be used on.

enter image description here

Now run the project, and... Viola!

Hilel answered 31/1, 2017 at 17:24 Comment(3)
yes i did it like 'tcl' not 'tlc'. But, i have several questions. 1st, yes i created a cocoa app like you suggested but where to save it and 2nd when i run the project nothing happens to my .tcl extension files, all of them are come with 'Generic' syntax highlighting not with 'AppleScript'.Ethiopic
@UmutKeskin 1) It doesn't matter were you put it. I store it on an external hard drive with all the rest of my dev projects. 2) I put the wrong value in the Conforms To section: it should be com.apple.applescript.text. Sorry about that.Hilel
I had some trouble trying to figure out the UTI for GLSL, since it's not in the link you provide. It's org.khronos.glsl-source and derived types. Here's the link: uti.schwa.io/identifier/org.khronos.glsl-source . If you're trying to find other types, a google search for something like "UTI glsl" should get you some hits.Lamentation

© 2022 - 2024 — McMap. All rights reserved.