Todo in xcode
XCode Apple Swift

Todo in xcode

Arturo
Arturo

The practice of leaving notes is important.

Commenting notes around your project helps you and your colleagues keep track of work that has been done, and what work still needs to be done.

Three keywords (TODO, FIXME, and MARK) have built in functionality in Xcode to help keep track of the many things that need to be done in your project. Additionally, with a little help from scripting, you can extend the functionality of these keywords to make sure your notes don’t go unnoticed.

We have the following to work on:

  1. //TODO: Some note...
  2. //FIXME: Some note...
  3. //MARK: — Some note...

By using a little bit of bash, Xcode will automatically throw you a warning or an error for any given comment tag.

Go to the build phases on your Xcode project file.

Click on the little plus sign at the top left and select New Run Script Phase. The idea here is that you’re adding another step to the build process when Xcode builds your project. If you unwrap the arrow for the run script item, you’ll see a black box that will hold script that Xcode will run on every build.

The code above can be found here:

Reveal Code

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

Now build your program. If you have any //TODO: or //FIXME: tags, Xcode will throw you a warning. If you write in an //ERROR: tag, Xcode will throw you an error and not run. (Note: you may have to move your script up in the build order.)

Employ this little trick, and never leave another item on your TODO list undone!


References:
Christopher Boynton