Xcode 使用 FIXME、TODO、???,?

发布于 2024-11-05 10:22:10 字数 175 浏览 3 评论 0 原文

我已经开始在 Xcode 中使用 FIXMETODO???!!! 标签,但有我发现当标签位于函数内时它无法识别标签,这很痛苦。这些标签仅在给定函数之外被识别。

如何在函数中识别这些标签(因为这是错误所在)?

I have started to use the FIXME, TODO, ??? and !!! tags in XCode but have am finding it painful that it does not recognise the tags when they are within a function. The tags are only recognised outside a given function.

How can I get these tags recognised within a function (as this is where the bugs are)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

一个人练习一个人 2024-11-12 10:22:10

在 xcode 4.1 中(不知道这在以前的版本中是否有效)我编写

#warning TODO: fix this later...

以获得编译警告或

#error FIXME: fix now!

编译错误。

我还将这些添加到代码片段库中,以便真正轻松地添加待办事项。

In xcode 4.1 (don't know if this works in previous versions) I write

#warning TODO: fix this later...

to get a compile warning or

#error FIXME: fix now!

to get a compile error.

I also add these to the code snippet library to make it really ease to add todos.

硬不硬你别怂 2024-11-12 10:22:10

解决方法是使用构建脚本将其标记为警告:

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

归功于 本杰明·拉格布

A workaround is to use a build script which marks those as warnings:

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

Credit to Benjamin Ragheb.

久随 2024-11-12 10:22:10

编辑于 2016-02-02

Xcode 现在支持 //MARK:、//TODO: 和 //FIXME: 地标来注释您的代码并在跳转栏中列出它们。


要查找这些特殊标记(实际上是您自己指定的任何标记),您可以使用搜索导航器,输入以下字符串,然后选择“在项目中,匹配正则表达式“...”,忽略大小写”:

(//FIXME|//!!!|//\?\?\?|//TODO)

这将搜索您的项目对于所有这些特殊标记。您甚至可以添加任何您想要的标记,例如“//REVIEW:请查看以下代码”。这将是以下搜索字符串:

(//FIXME|//!!!|//\?\?\?|//TODO|//REVIEW)

我在工作区中创建了一个选项卡,其中搜索导航器始终打开,并填充了该字符串。不幸的是,XCode 有时会从搜索框中删除该字符串,因此您必须在需要时准备好复制和粘贴。

Edited 2016-02-02

Xcode now supports //MARK:, //TODO: and //FIXME: landmarks to annotate your code and lists them in the jump bar.


To find those special markups (and actually any markups you specify yourself), you can use the search navigator, enter the following string and then choose "In Project, matching regex "...", ignore case":

(//FIXME|//!!!|//\?\?\?|//TODO)

This will search your project for all those special markups. You can even add any markup you would like to, e.g. "//REVIEW: please review the following code". This would then be the following search string:

(//FIXME|//!!!|//\?\?\?|//TODO|//REVIEW)

I created a tab in my workspace which has the search navigator always open, filled with this string. Unfortunately, XCode will sometimes remove this string from the searchbox, so you have to have it copy&paste ready whenever you need it.

可是我不能没有你 2024-11-12 10:22:10

FIXME:、TODO:、???: 和 !!!: 在 4.3.3 的函数内部和外部工作。

双斜杠之前或之后可以有任意数量的空格,但必须使用大写字母并在标签后面加冒号。

只是为了说清楚 - 所有这些都有效:

//          FIXME: This works.
  //TODO: This works.
    //                  !!!: Working.
// // //???: Works as well.

The FIXME:, TODO:, ???: and !!!: works in 4.3.3 inside and outside of functions.

You can have any number of whitespace before or after the double slash, but you have to use uppercase and follow the tag with a colon.

Just to make it clear - all of these work:

//          FIXME: This works.
  //TODO: This works.
    //                  !!!: Working.
// // //???: Works as well.
冬天旳寂寞 2024-11-12 10:22:10

这个 Xcode 插件怎么样? --> https://github.com/trawor/XToDo

how about this Xcode plugin? --> https://github.com/trawor/XToDo

江挽川 2024-11-12 10:22:10

xCode 6 beta 4 应该支持 MARK、TODO 和 FIXME 地标。

Xcode 现在支持 //MARK:、//TODO: 和 //FIXME 地标来注释您的代码和
将它们列在跳转栏中。 (14768427)!

xCode 6 beta 4 should support MARK, TODO and FIXME landmarks.

Xcode now supports //MARK:, //TODO: and //FIXME landmarks to annotate your code and
lists them in the jump bar. (14768427)!

皓月长歌 2024-11-12 10:22:10

请注意,但我注意到 TODO: 在任何类型的块中都不起作用。只需将其移至您的方块的正上方或下方即可。

Just a heads up, but I've noticed the TODO:'s do not work within blocks of any kind. Just move it right above or below your block.

绝影如岚 2024-11-12 10:22:10

这是我用作附加构建阶段的脚本,请注意,它排除了通过 Carthage 拉入的文件(否则获取这些文件也非常烦人,因为它不是“您的”代码):

TAGS="WARNING:|TODO:"
echo "searching ${SRCROOT} for ${TAGS}"
find "${SRCROOT}" \( -name "*.swift" \) -not -path "${SRCROOT}/Carthage/*" -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/"

在带有 Swift 4 的 xCode 9.3 上运行良好

This is the script I use as an added build phase, note it excludes files pulled-in via Carthage (very annoying to get these as well otherwise since its not 'your' code) :

TAGS="WARNING:|TODO:"
echo "searching ${SRCROOT} for ${TAGS}"
find "${SRCROOT}" \( -name "*.swift" \) -not -path "${SRCROOT}/Carthage/*" -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/"

Works well on xCode 9.3 with Swift 4

白首有我共你 2024-11-12 10:22:10

如果您想继续开发,但需要确保您的应用发布时不会留下剩余的//FIXME:,您可以执行以下操作作为替代方案。

在标头之一中的某处定义此定义:

#if DEBUG
#define FIXME 0;
#endif

此定义允许您的应用程序构建用于调试,但阻止其存档以供发布。

现在,您可以在任何要使用注释的地方使用 FIXME

例如:NSNumber *magicNumber = 7;修复我

If you want to continue developing but need to ensure your app doesn't get released with a leftover //FIXME: you can do the following as an alternative.

Define this somewhere in one of your headers:

#if DEBUG
#define FIXME 0;
#endif

This definition lets your app build for debug but prevents it from being archived for release.

Now you can use FIXME anywhere you would've used the comment.

Ex: NSNumber *magicNumber = 7; FIXME

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文