JEscala JEscala - 5 months ago 21
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
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).