//TODO: — Make your notes on Xcode stand out

The practice of leaving notes is important.

Image for post
Image for post
Pictured: J. Walter Weatherman

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.

Play along at home to see how this works!

Keywords

Image for post
Image for post
Find this above your code editor

Clicking on this last item will show a dropdown menu, listing the properties, methods, or whatever else is happening in your file. This helps read and navigate files with many lines of code, with many functionalities.

Image for post
Image for post
Your table of contents

Xcode also allows you to place your own items in this list, so that others, or maybe even yourself after a long week, can get a quick diagnostic on the file to see if things need to be done or need to be fixed.

For example:

//TODO: Add method to find needle in a haystack

…will produce this, with a bulleted list icon:

Image for post
Image for post

This:

//FIXME: Remove all references to jiltedExLover

…will produce this message, with an bandage icon:

Image for post
Image for post

For another trick, adding a dash (-) after the colon on any note will create a line break in your dropdown list. So this:

//MARK: — Distinct Section

…will produce this message with a line break over it:

Image for post
Image for post

Got it? Great!

Generating Warnings and Errors with Comments

Guess what?

There is!

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.

Image for post
Image for post
Select the project, then move to the build phases

Click on the little plus sign at the trop right and select Run New 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.

Image for post
Image for post
The run script box

Now copy and paste this into that box:

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!

Image for post
Image for post

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store