How to print in debug console on Xcode – Swift

There is no special technique to print something in the debug console of Xcode while dealing with SwiftUI or StoryBoard.

You can simply use the print statement.

print("Hey print this in Xcode debug console")

I will show you an example.

I created a UIButton and added the code below in my ViewController.

 
@IBAction func cPressed(_ sender: Any) {
    print("I am pressed")
    
    }

I named the button action cPressed

So what I did is just added the IBAction in my ViewController and my object is to print something if I press the UIButton.

If I run this app and click on my Button it will print the below line in my debug console area.

I am pressed

print in debug xcode

If you want to print more information or inferred type to the output you can use debugPrint().

If you are not able to find the debug console area, then you can follow the below tutorial:

Xcode Debug Console Area not Showing or Missing – Fixed

Leave a Reply

Your email address will not be published. Required fields are marked *