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 callUIApplicationMain
(iOS),NSApplicationMain
(Mac OS X), orCFRunLoopRun
on the main
thread must not calldispatch_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.
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
Swift 2 to 3 Migration Dispatch_Get_Global_Queue
How to Convert Uint16 to Uint8 in Swift 3
Load Desktop Version Wkwebview iOS 9
Naming Convention for Optional Binding
Cannot Add Alamofire to Swift Project
How to Subclass Nsoperation in Swift to Queue Skaction Objects for Serial Execution
Uibarbuttonitem Selector Not Working
Making Swift Generics Play with Overloaded Functions
How Do Generators Whose Element Is Optional Know When They'Ve Reached the End
How to Access Firebase Variable Outside Firebase Function
Fblpromises Framework Not Found
How to Set an Environment Object in Preview
Compare Three Values for Equality
Why Is Swift's Ternary Operator So Picky About Whitespace
Swift [1,2] Conforms to Anyobject But [Enum.A, Enum.B] Does Not