Show Xcode compiling warnings for FIXME and TODO with Swift
This solution is based on Swift 3 and Xcode 8.
Sometimes it is just too easy to let some debugging code or unfinished logic slip into the code commit or even release build. The popular way to remind ourselves is to add comments beginning with FIXME or TODO. A simple search for those key words would help to find and fix those bits of code. But this extra step can be easily forgotten.
Instead of saying “Oh, sh*t” later on, it would be much better to show those comments as warnings during compiling time in Xcode. It is where most of the attentions are paid on. Apple does not provide a way to archive this feature. However, we can simply add a build script to the “Build Phases” in Xcode to show those warnings. You can find the sample warnings and comments below:
Much better, isn’t it?
Steps to add this feature to Xcode:
- Copy the script below
2. Open Xcode and go to the “Build Phases” of the settings of your app’s target, as below:
3. Click on the “+” and select “New Run Script Phase”
4. In the new phase created, paste the script copied
That’s it! Wala! Off you go!
In this script, I used FIXME! and TODO! to distinguish from the normal FIXME: and TODO:. Because those comments are so common that the script may pick up the warnings from your libraries.