Adding syntax coloring to Xcode for unknown file extension such as “.tcl”

半腔热情 提交于 2019-12-18 05:25:08

问题


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...


回答1:


Yes there is.

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

Then go to Info -> Exported UTIs:

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.

Now run the project, and... Viola!



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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!