Sometimes I want to prevent myself from accidentally committing a temporary change I've made for the build I'm currently running. In Objective-C this used to be accomplished by adding a simple #warning statement, but the Swift compiler does not offer a similar feature.

Luckily we use SwiftLint for the project I'm currently working on, which offers the ability to add custom validation rules. Swiftlint throws warnings for code that matches a validation rule, so we can use this system to throw a warning when we need it.

This custom rule for SwiftLint triggers a warning when it detects a comment containing // WARNING or // warning. Xcode will now display a warning when building the following code.

// WARNING: remove true flag
if isAuthenticated || true {

}