Searene
Searene

Reputation: 27544

How to print to the Debug Area with Swift UI in Xcode 13?

I want my print message to be shown in the Debug Area in Xcode 13. There are several questions like this on StackOverflow, some of them suggest using the Debug Mode, which seems to have been removed in Xcode 13.

Here is my ContentView:

struct ContentView: View {
    var body: some View {
        Button("button", action: {
            print("abc")
        })
    }
}

Though I use print("abc"), when I click the button, there's nothing in the Debug Area. How to show it?

Debug Area

Upvotes: 2

Views: 2115

Answers (1)

matt
matt

Reputation: 534893

The problem is that you're not running the app. You're just looking at the preview. Press Command-R and run the app in a simulator; tap the button in the simulator.

Note that when you're actually running the app, the debug bar (at the top of the debug area) looks quite different:

enter image description here

Upvotes: 2

Related Questions