Print TODO/FIXME Comment as Warning in XCode
When I’m implementing new functionality I start with the general design and then I’m implementing newly created classes and methods. Sometimes I leave a method or two for later implementation (i.e. after creating unit test for this method) and almost always putting comment:
// TODO: nice comment here
It already happened to me, that I left this comment unnecessary or (the worst case scenario) I forgot to implement this TODO part 😦 To get rid of these mistakes you can add Run Script phase in Build Phases of your project’s target with some nice shell command. To do this, click on your target, move to Build Phases tab and in right-bottom corner click Add Build Phase and choose Add Run Script. Leave shell as it is and in the content of the script paste following two lines:
KEYWORDS="TODO.*:|FIXME.*:|\?\?\?.*:|\!\!\!.*:" find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.mm" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/"
| grep -v ExternalSources