In SwiftUI, you can use the print() function to print messages to the console, which is similar to the console.log() function in JavaScript. Here is an example:
ContentView: View {
var body: some View {
Button(action: {
print("Button clicked!")
}) {
Text("Click me")
}
}
}
In this example, the ContentView struct has a Button that calls the print() function when tapped. The print() function takes a string argument, the message that will be printed to the console. In the above case, the message is “Button clicked!”.