Disabling print for Production In Swift Project


You'll need to set up a compiler flag to use the Swift preprocessor - go to the Swift Compiler - Custom Flags section of Build Settings to set up a -D DEBUG flag:




Then in your code you can define a DLog() function and only print your message if the DEBUG flag is set:

func DLog(message: String, function: String = __FUNCTION__) {
    #if DEBUG
    println("\(function): \(message)")
    #endif
}

Comments

Popular posts from this blog

How to show activity indicator in watch kit

Vector graphics in iOS

Exception Handling - Objective C