How can I print to console in Swift Playgrounds on iPad?

后端 未结 3 442
南旧
南旧 2021-01-25 06:50

I would like to debug a method deep inside my \"Sources\" folder within a Swift Playground.

public func wannaDebugThis         


        
3条回答
  •  清歌不尽
    2021-01-25 07:14

    In order to write debug messages from the iPad to the console, NSLog() has to be used.

    public func wannaDebugThis() {
        let x = 42
        let text = "Debug message with useful information: x = \(x)"
        NSLog(text)
    }
    

    The output of NSLog() can be found under the process named ExecutionExtension in Console.app on macOS. The output of print messages is only shown as , which can be seen on attached screenshot.

提交回复
热议问题