How to clear console programmatically in Xcode?

21,516

Solution 1

Maybe you could use the "Auto Clear Debug Console" setting in the Xcode Preferences...

Don't know if this answers your question?

Solution 2

When in the console (Debug mode), use:

Xcode > Debug > Debug Workflow > Clear Console

Keyboard Shortcut: Command ⌘+K

Solution 3

Swift

print("any value", terminator: Array(repeating: "\n", count: 100).joined())

Objective-C

I think the only thing you can is

for(int i= 0; i < 100; i++) 
NSLog(@" ");

just like in good old MS-DOS :)

Solution 4

If you are talking about the console in the Xcode window there is a "Clear Console" option in the "Run" menu. There is also, in the "Debugging" Preferences tab an "Auto Clear Debug Console" checkbox. I am referring Xcode 3.2.x

Solution 5

The debugger console / run log are basically a redirected "log this to the console" command from your app. "Clearing" it means nothing in the general sense, since the messages are usually just shunted somewhere (like a file). Your application would have to know about its debugging environment and be able to tell that environment to clear whatever it's logging to.

In short: I suppose it's not impossible but it's ridiculously inconvenient.

Share:
21,516
NSExplorer
Author by

NSExplorer

Updated on July 09, 2022

Comments

  • NSExplorer
    NSExplorer almost 2 years

    I have a bunch of NSLog statements in my code which I use for debugging. Every time I run my Project I'd like to start from a fresh console screen. Is there any command I can embed in my code which can do this?