在Xcode IDE中使用// TODO注释 [英] Using the // TODO comment with the Xcode IDE

查看:101
本文介绍了在Xcode IDE中使用// TODO注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我IDE是应该这样工作的还是我不理解// TODO注释功能是如何工作的。当我放置// TODO时,Xcode在跳转栏中添加了TODO部分。多个TODO使用TODO注释作为部分标题放置了多个部分。

Can some one tell me if this is how the IDE is supposed to work or if I am not understanding how the // TODO commenting feature works. When I place a // TODO, Xcode adds a TODO section in the jump bar. Multiple TODO's places multiple sections with the TODO comment as the section title.

我看到的问题是,在我的TODO注释之后出现的任何方法都包括在内跳转栏中的TODO部分。为什么Xcode会在注释之后自动添加所有方法,作为TODO的一部分?

The issue that I am seeing, is that any method that comes after my TODO comment is included as part of the TODO section in the jump bar. Why does is Xcode just automatically adding all of the methods after my comment as part of the TODO ?

也许我错过了为什么这样做的意思,或者也许我我做错了。有人可以为我提供一些澄清吗?

Perhaps I am missing the point of why it does this, or maybe I am doing this wrong. Could someone provide some clarification on this for me?

谢谢!

推荐答案

不确定是否有 // TODO 特殊注释标记。有 TODO: FIXME: MARK: MARK:-(放置分隔符)。 MARK:-某些文本将放置一些带有分隔符的文本。还有 // ???: // !!!:-它们也会产生标记-只是试试看(它们可能在Swift中不起作用)。

Not sure if there is a // TODO special comment mark. There are TODO:, FIXME:, MARK:, MARK: - (to put separator). MARK: - Some Text will put a some text with separator. Also there are // ???: and // !!!: - they produce marks as well - just try them (they might not work in Swift).

// TODO 而没有不会创建任何标记(从Xcode 10开始)。

// TODO without : does not create any marks (as of Xcode 10).

您可以在构建时使用某些类型的注释来生成警告。
选择项目-> 构建阶段,然后按 +按钮添加另一个阶段。创建时选择运行脚本。添加为脚本主体(确保Shell为 / bin / sh ):

You can use certain types of comments to produce warnings at build time. Select Project -> Build Phases, press '+' button to add another phase. Choose Run Script on creation. Add as a body of script (make sure Shell is /bin/sh):

KEYWORDS="TODO:|FIXME:|\?\?\?:|\!\!\!:"
find "${SRCROOT}" \( -name "*.swift" \) -print0 | \
xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | \
perl -p -e "s/($KEYWORDS)/ warning: \$1/"

现在,在构建时,您会收到带有注释文本的警告。

Now when you build, you'll get warnings with the text of comments.

您可以将关键字限制为修复和!只要。
要预先获得这些警告(而不等待实际的构建),只需将新创建的运行脚本部分移到顶部。

You are free to limit KEYWORDS to fixes and !!! only. To get these warnings upfront (and not wait for the actual build) just move the newly created Run Script section to the top.

这篇关于在Xcode IDE中使用// TODO注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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