crashoverride777 crashoverride777 - 1 year ago 125
Swift Question

Swift 2 print(), how to hide?

prior to Swift 2 you could hide all your println() for release by having a little helper like this

func println(object: Any) {


If you change this to

func print(object: Any) {


it works as expected however print() has a new appendLine feature. So in your code you could write

println("Test", appendNewLine: false)

Doing this however means the above mentioned helper will not work anymore. Any suggestions of how to fix this. Thank you very much.

Answer Source

For swift 2.2, here's what I use:

// Disable print for production.
func print(items: Any..., separator: String = " ", terminator: String = "\n") {
    #if DEBUG
    Swift.print(items[0], separator:separator, terminator: terminator)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download