swiftxcodedebuggingloggingansi-colors

print() to console log with color


The code is:

let redColor = "\u{001B}[0;31m"
var message = "Some Message"
print(redColor + message)  //This doesn't work
print("\(redColor)\(message)") //This also doesn't work

and the output would look like this:

[0;31mSome Message

I've also read this post: Color ouput with Swift command line tool, and it doesn't seem to work.

I don't want to use libraries.


Solution

  • Nowadays, Xcode debugging console doesn't support coloring.