Search code examples
swiftxcodeprintingtextcolor

Xcode: How to print colored PRINT statement in console output?


I am new to Swift and I was wondering if it is possible to print colored print statement in the console of Xcode..

Here's an example:

print("Hi my name is John Doe")

now I want to print this statement in red color, how would I do that?


Solution

  • That feature has been killed by Apple from Xcode 8. But you can use SwiftyBeaver to achieve it.

    let log = SwiftyBeaver.self
    let console = ConsoleDestination()
    log.addDestination(console)
    
    // default xcode colors
    console.levelColor.verbose = "💜 "