JEscala JEscala - 1 year ago 93
Swift Question

How can I output to STDERR with Swift?

I'm trying to make a command line tool for OS X with Xcode 6 and the new Swift language. How can I send output to stderr? Is this done with println?

Answer Source
import Darwin
fputs("hello from libc\n", __stderrp)

Note that stderr is not supported in Playgrounds or the REPL and will crash in both of those places (as of Swift 1.1).