在XCode4中显示TODO FIXME等标记

来源:互联网 发布:淘宝发货单打印软件 编辑:程序博客网 时间:2024/06/05 07:31

在XCode 3,我们可以用类似这样的注释来方便我们标记需要修改的部分:

// TODO:
// FIXME:
// !!!:
// ???:

XCode 4不支持这一功能了,网上有一种解决方法, 转发过来:

原文: http://deallocatedobjects.com/posts/show-todos-and-fixmes-as-warnings-in-xcode-4


Here's a neat little snippet for Xcode 4 that will cause all of your //TODO: and//FIXME: comments in your code to appear as compiler warnings when you build. Here's how to use it:

Instructions

  • 进入项目属性设置那个页面
  • 选择一个Target
  • 选择Build Phases标签
  • 点击右下角的Add Build Phase
  • 展看上面刚出现那一栏Run Script,输入以下内容

  • Head over to your project's item in the Project Navigator (usually at the very top)
  • Find your target in the list of targets on the left, select it
  • Head over to the "Build Phases" tab.
  • Click the "Add Build Phase" in the bottom right of this screen.
  • In the editor that appears insert the bash script shown below.

Now just build and you'll see all your //TODO: and //FIXME: comments have become warnings. I love this technique, it might not be right for everyone, but hope it helps someone.

Bash Script For "Run Script" Build Phase

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

You'll also be able to click on each of the warnings in the issue navigator to go right to the file and point in your code where you left the original//TODO: or//FIXME:

Extra pro tip: Make sure you're using phrases to describe your //TODO: comments like//TODO: Handle this error gracefully, and things like that. The phrases will show up in the issues list beside each warning.



这样就可以在Document Item里面显示, 在编译后的警告里面也会有提示!

原创粉丝点击