为未知文件扩展名(例如".tcl")向Xcode添加语法颜色. [英] Adding syntax coloring to Xcode for unknown file extension such as ".tcl"

查看:89
本文介绍了为未知文件扩展名(例如".tcl")向Xcode添加语法颜色.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一个有关Xcode语法着色(突出显示)的问题.我一直都在使用文件.tcl文件,并且Xcode不知道扩展名,默认情况下,它使用"Generic"语法着色选项打开它们.在这种情况下,语法着色部分中的"AppleScript"非常适合扩展名为.tcl的文件,以便查看代码中不同内容的所有颜色.因此,如何为.tcl文件添加新选项,或者如何更改在Xcode中打开.tcl文件时出现的通用"选项?有没有办法做到这一点,因为默认情况下使用"AppleScript"语法着色打开.tcl文件?

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 ?

谢谢您的回答...

推荐答案

是的.

您需要做的是在Xcode中创建一个新的macOS项目(我将其称为SyntaxHighlighting:

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

然后转到Info -> Exported UTIs:

单击加号按钮.将Identifier设置为类似com.umutkeskin.tcl-source的内容.

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

Conforms To部分告诉您UTI将使用哪些突出显示.您可以查看系统定义的统一类型标识符的完整列表

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.

Extension设置为tcl.这将设置将使用此UTI的文件扩展名.

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

现在运行项目,然后... Viola!

Now run the project, and... Viola!

这篇关于为未知文件扩展名(例如".tcl")向Xcode添加语法颜色.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆