Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I output to STDERR with Swift?

Tags:

macos

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?

like image 837
JEscala Avatar asked Jun 04 '14 15:06

JEscala


People also ask

How do I print to stderr?

Use the fprintf Function to Print to stderr in C The standard I/O library in C provides three text streams that are opened implicitly when the program is started on the system. These streams are, standard input ( stdin ) - used for reading input. standard output ( stdout ) - used for writing output.

What does print mean in Swift?

You use print() in Swift to print a string of text to the Console, or standard output. It's super useful for debugging and finding out what's going on in your code.


1 Answers

For Swift 4.x:

import Darwin fputs("hello from libc\n", stderr) 
like image 103
i40west Avatar answered Sep 30 '22 18:09

i40west