How to make Xcode recognize a custom file extension as Objective-C for syntax highlighting?

后端 未结 3 1280
小鲜肉
小鲜肉 2021-02-01 02:02

I\'d like to get Xcode 4 to recognize a custom file extension (e.g. *.lx) as Objective-C for syntax highlighting and indentation purposes. How do I get the tool to automatically

3条回答
  •  北荒
    北荒 (楼主)
    2021-02-01 03:04

    Xcode has a "Type" field in the "Attributes Inspector" (leftmost tab in "Utilities" right sidebar) for files in your project:

    As you can see above, I set our project's Fastfile to be recognized as a Ruby Script—which it is, despite lacking the expected .rb extension. Yielding the expected syntax highlighting (with my custom color scheme):

    Note: this only works if the file is added to your project within a group (not inside a folder reference):

    This might not be ideal, but Xcode can't persist attributes of files which aren't explicitly tracked in the project file. Folders, by design, don't have entries for their contents in the Xcode project, since it's meant to be dynamic.

提交回复
热议问题