Xcode 使用 FIXME、TODO、???、?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5891193/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode using FIXME, TODO, ???,?
提问by Ben
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.
我已经开始使用FIXME
,TODO
,???
和!!!
XCode中的标签,但我已经发现它的痛苦,它并不能识别标签时,他们是在一个函数中。标签只能在给定函数之外被识别。
How can I get these tags recognised within a function (as this is where the bugs are)?
如何在函数中识别这些标签(因为这是错误所在)?
采纳答案by Florian
Edited 2016-02-02
编辑 2016-02-02
Xcode now supports //MARK:, //TODO: and //FIXME: landmarks to annotate your code and lists them in the jump bar.
Xcode 现在支持 //MARK:, //TODO: 和 //FIXME: 地标来注释您的代码并在跳转栏中列出它们。
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:
这将在您的项目中搜索所有这些特殊标记。您甚至可以添加您想要的任何标记,例如“//REVIEW:请查看以下代码”。这将是以下搜索字符串:
(//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.
我在我的工作区中创建了一个选项卡,其中搜索导航器始终处于打开状态,并填充了此字符串。不幸的是,XCode 有时会从搜索框中删除此字符串,因此您必须在需要时准备好复制和粘贴。
回答by loomer
In xcode 4.1 (don't know if this works in previous versions) I write
在 xcode 4.1(不知道这是否适用于以前的版本)我写
#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.
我还将这些添加到代码片段库中,以便真正轻松地添加待办事项。
回答by frank
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.
感谢本杰明·拉吉卜。
回答by Johan
The FIXME:, TODO:, ???: and !!!: works in 4.3.3 inside and outside of functions.
FIXME:, TODO:, ???: 和 !!!: 在 4.3.3 内部和外部函数中工作。
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.
回答by Travis Worm
how about this Xcode plugin? --> https://github.com/trawor/XToDo
这个 Xcode 插件怎么样?--> https://github.com/trawor/XToDo
回答by Ramis
xCode 6 beta 4 should support MARK, TODO and FIXME landmarks.
xCode 6 beta 4 应该支持 MARK、TODO 和 FIXME 地标。
Xcode now supports //MARK:, //TODO: and //FIXME landmarks to annotate your code and lists them in the jump bar. (14768427)!
Xcode 现在支持 //MARK:, //TODO: 和 //FIXME 地标来注释您的代码并在跳转栏中列出它们。(14768427)!
回答by Yarmoshy
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.
只是提醒一下,但我注意到 TODO: 在任何类型的块内都不起作用。只需将其移动到块的正上方或下方即可。
回答by HixField
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) :
这是我用作附加构建阶段的脚本,请注意它不包括通过 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/"
Works well on xCode 9.3 with Swift 4
使用 Swift 4 在 xCode 9.3 上运行良好
回答by lundhjem
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.
如果您想继续开发但需要确保您的应用程序不会随剩余产品一起发布,//FIXME:
您可以执行以下操作作为替代。
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.
现在你可以FIXME
在任何你会使用评论的地方使用。
Ex: NSNumber *magicNumber = 7; FIXME
前任: NSNumber *magicNumber = 7; FIXME