Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to view print messages in Xcode?

Tags:

xcode

swift

How can I see the messages being printed at runtime in Xcode?

For example the following line:

print("Testing")
like image 364
tcirone Avatar asked Apr 27 '16 02:04

tcirone


People also ask

How do I display print in Xcode?

Press ⇧⌘Y or choose View > Debug Area > Show Debug Area to show the console output (or ⇧⌘C / Activate Console). Usually, this window will open automatically when your program produces output (this is controlled by the Behaviors section of Xcode's Preferences). Save this answer. Show activity on this post.

Where is output in Xcode?

Go to Xcode → Preferences → Debugging → On Start → "Show Console". Save this answer.

How do I print a view in SwiftUI?

Use print statement inside SwiftUI view You need to assign print() to a variable ( var ) or a constant ( let ). Here is an example of how we can use print() in a SwiftUI view. Text("Hello, World!") 1 and 2 We don't use the returning result ( x and y ) anywhere.


2 Answers

Press ⇧⌘Y or choose View > Debug Area > Show Debug Area to show the console output (or ⇧⌘C / Activate Console). Usually, this window will open automatically when your program produces output (this is controlled by the Behaviors section of Xcode's Preferences).

enter image description here

like image 78
jtbandes Avatar answered Oct 13 '22 00:10

jtbandes


XCode 11 + SwiftUI Users having the same issue, the answer is that you need to right-click the play button in the preview window to turn on debug preview! Assuming that you have the debug area active (view > debug area > activate console), as seen in:

enter image description here

like image 20
punkbit Avatar answered Oct 13 '22 01:10

punkbit