Coding with Titans

so breaking things happens constantly, but never on purpose

HowTo: Find and mark all FIXME / TODO in Xcode project

This time it won’t be a guide I came up myself from scratch. Recently I joined a totally new Swift project and wanted to quickly understand, what it does. Then I had an idea of navigating and finding issues, that were left there by my fellow previous developers. Those specially marked lines are usually left there and aren’t meant to be brought to light. Mentally they can be ignored for years by their creators. Unfortunately Xcode 12 has still no feature to scan though the source code and highlight lines described as FIXME nor TODO.

Gladly I found the answer to this problem on Although I think I’ve heard about this trick for the first time from the PluralSight’s course: iOS Debugging in Xcode by Matthew Kruczek. I also found it described on another blog post here.

The trick here is simple: use find & egrep to scan over all files within the project and for every matching line print a warning, which Xcode can understand and put inside build results window. It’s illustrated down below.

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

However what I found useful to include there is:

  • change the list of keywords to include HACK as barely no one uses DevTeam or XXX nowadays
  • avoid searching inside Pods folder as I won’t need to change there anyway and I don’t want to bloat my warnings list if I have too many dependencies.

Then my tweaked version looks like following:

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

It can be simply added as Run Script Build Phase inside a selected target and the script can be copied there.

Run Script Build Phase

🐹 👍