Nothing Prints Out in the Console in Command Line Tool Xcode

Nothing prints out in the console in command line tool Xcode

Applications – such has command-line programs – which do not already have a "run loop" have to call

dispatch_main() // Swift 2
dispatchMain() // Swift 3

in order to use GCD. From the documentation:

This function "parks" the main thread and waits for blocks to be
submitted to the main queue. Applications that call UIApplicationMain
(iOS), NSApplicationMain (Mac OS X), or CFRunLoopRun on the main
thread must not call dispatch_main.

Xcode not showing anything in console with C++

Your image doesn't show that you ran the program, only that you built it. Look at the Log Navigator (the last one, ⌘7) and see if there are any logs for 'Debug one' after 'Build one'. To run the program use Product > Run or ⌘R.

Swift: print() command not printing to console in Xcode 7.3.1

You need to set/add a breakpoint because sometimes methods in other files for example with recursive blocks or segues could be preempting the call of the print line. If you see your print statement after you have set a break point then you know something which is getting called is preempting the call of the print statement.

Adding, Disabling, and Deleting Breakpoints

Also, this may sound obvious so don't shoot me, but many people mistakenly disable the console view. shift+command+C shows the console
view.

In addition, you can also use nslog to print to device logs to see if it makes a difference. nslog adds time-stamps etc. NSLog("Can anyone hear me?") Then go to Xcode -> Window -> Devices and check the device logs. You can also check OS X Console Application for the same logs.

Xcode not showing console output; How do you flush the console?

If you're practicing c try fflush, if c++ try cout << endl; each time you want to print.

No output for console application in Xcode

cout is typically line-buffered - add a std::endl:

std::cout << "Cannot load image" << std::endl;

Xcode 4 - Debug Area no longer shows my console output (NSLog)

Not sure but may be you have clicked on one of the three buttons at the top right corner of the debug area that are used to either show only variables view, only the console or both.

po command in Xcode does not generate output

Silly me, I was in the 'Target Output' window instead of the 'Debugger Output' window.

Sample Image

Somehow I thought I checked the other console windows there, but apparently I didn't.

How to print something to the console in Xcode?

@Logan has put this perfectly. Potentially something worth pointing out also is that you can use

printf(whatever you want to print);

For example if you were printing a string:

printf("hello");


Related Topics



Leave a reply



Submit