Xcode using FIXME, TODO, ???,?

时光怂恿深爱的人放手 提交于 2019-12-02 14:38:50
Florian

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.

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.

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.

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.

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

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)!

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!