[Home] [Up] [Previous] [Next]

radq.ca


Open the Console in Terminal in Xcode: Fun with ANSI Escape Codes

May 19th, 2022

I just learned/noticed you can run your console application in a seperate terminal window outside of Xcode, while still connected to Xcode's debugger. Xcode's console does not seem to nicely display ANSI colour or control sequences unfortunately but running it in the Terminal app helps with that.

Just open the scheme editor of your console based app, make sure Run on the left is selected, the options tab up top is selected, and look at the bottom:

The location of the option to run from the terminal in Xcode.

This will change your ANSI related output from this (in Swift using Xcode):

Bad ANSI output example.

To this in Terminal.app:

Good ANSI output example.

This also allows you to do nice ANSI control characters like setting the position of the cursor before you draw text to the screen.

For more info check out this fun wikipedia page Ansi escape code, and for a real how-do-you-do check out everything you ever wanted to know about terminals.

Following the instructions from this page from the previously mentioned site is very fun as well.


© 2024 radq.ca