Swift: #warning equivalent

Edit

As of Swift 4.2, language level support is available for both build warnings and errors.

#warning("Warning description")
#error("Throws a build error")

Original Answer

Quick, dirty, and oh so elegantly simple all at the same time.

// Description of what you need to fix

var FIX_ME__🛠🛠🛠: AnyObject

Throws a warning that ‘FIX_ME__🛠🛠🛠’ was never used.

You can add emoticons to the variable name if you like… I often use 😱 and 🛠, for something that really needs fixing I’d even consider 💩. You can replace FIX_ME__ with whatever you want: ALGORITHM_NEEDS_REVIEW, BugID_148, or JOHNNY_YOU_BROKE_THIS are some examples.

Quick, no setup, concise, and emoticons can even add humour/personality to your code. Sometimes the most simple solution is the best solution.

Leave a Comment