ToDo, FixMe, Warning & Error | Code Documentation | Xcode Tips | Part 1

Documentation is one of the most important aspects of software development.

Comprising of a number of techs it is really essential to keep clear and consistent code.

Fortunately, in this article, we will discuss some documentation comments that are available in Xcode.

TODO: This comment tag is mostly used as a placeholder for future refactoring. Want to let your teammates know that something needs to be done? This is a neat option. And our smart Xcode will conveniently show this in its source navigator.

Xcode source navigator showing a TODO marked statement

FIXME: A comment tag to show that something needs to be fixed in the code. I personally use #TODO tag most of the time but no doubt this is indeed a better option to denote a fix more specifically. You use a #TODO tag when something is pending as a functionality or improvement in the code.

A typical case of FIXME tag

But the above two come with a certain limitation. Can you guess?

If you’ve guessed that one needs to anyway search for these in the source navigator you are right. Luckily, the next two in the row came for a rescue.

#warning: You must have noticed I’ve placed a (#) pragma mark before the warning keyword. This means that it is a compiler directive. It will force Xcode to issue a warning when building your code.

That’s great right?

A custom warning right next to your code. How cool!

#error: This directive will issue a compile error so the code won’t build at all. It is very helpful when you want others to modify the code before continuing. A typical use case is when you need a developer to provide a custom API key for your library.

Unravel the error 😈

Summary:

We have understood some basic Xcode tips to increase efficiency, reduce P2P communication, and ultimately minimise errors at the time of development.

I would love to hear from you

You can reach me by the following channel(s):

LinkedIn

Thanks for reading. Happy code documenting!

Note: I will publish a second part very soon. Stay tuned!

iOS developer