Xcode将哪些来源注释识别为标签?

Mat*_*ing 38 xcode comments

这主要是出于好奇心.我已经知道Xcode能够以形式识别评论// TODO: Something I don't feel like doing now.将该行添加到文件源将导致该TODO注释显示在Xcode的导航栏中:

在此输入图像描述

我最近还发现表单的注释// MARK: Something可以达到与#pragma mark某些东西相同的效果.所以我可以写一个看起来像这样的评论:

// MARK: -
// MARK: Future Improvements:
// TODO: Make something better
// TODO: Fix some bug
Run Code Online (Sandbox Code Playgroud)

Xcode会像这样呈现出来:

在此输入图像描述

这让我想知道:Xcode可以理解其他类型的评论来改进项目导航吗?

Pau*_*l R 36

还有MARK,FIXME,!!!???,如

// FIXME: this bug needs to be fixed
Run Code Online (Sandbox Code Playgroud)

// ???: WTF ???
Run Code Online (Sandbox Code Playgroud)

您可以在/Applications/Xcode.app/Contents/OtherFrameworks/XcodeEdit.framework/Versions/A/Resources/BaseSupport.xclangspec(或/Developer/Library/PrivateFrameworks/XcodeEdit.framework/Resources/BaseSupport.xclangspec旧版本的Xcode)中查看这些内容的定义.大概你也可以在这里添加你自己的标签,但我还没有尝试过.以下是相关部分BaseSupport.xclangspec:

{
    Identifier = "xcode.lang.comment.mark";
    Syntax = {
        StartChars = "MTF!?";
        Match = (
            "^MARK:[ \t]+\(.*\)$",
            "^\(TODO:[ \t]+.*\)$",       // include "TODO: " in the markers list
            "^\(FIXME:[ \t]+.*\)$",      // include "FIXME: " in the markers list
            "^\(!!!:.*\)$",              // include "!!!:" in the markers list
            "^\(\\?\\?\\?:.*\)$"         // include "???:" in the markers list
        );
        // This is the order of captures. All of the match strings above need the same order.
        CaptureTypes = (
            "xcode.syntax.mark"
        );
        Type = "xcode.syntax.comment";
    };
},
Run Code Online (Sandbox Code Playgroud)

BBEdit文本编辑器及其免费软件兄弟TextWrangler也支持这些标记.

  • 在Swift中,```和`!!!`似乎不适用于Xcode 8.2.1(它们仍适用于Objective-C) (2认同)

Pat*_*ini 23

好像

// MARK:
// TODO:
// FIXME:
// ???:
// !!!:
Run Code Online (Sandbox Code Playgroud)

所有都被翻译成#pramga-like标记.

它们似乎代表着它

// Mark, as in pragma
// To Do note
// Known bug marker
// Serious question about form, content, or function
// Serious concern about form, content, or function
Run Code Online (Sandbox Code Playgroud)