I would like to debug a method deep inside my \"Sources\" folder within a Swift Playground.
public func wannaDebugThis
This feature has been added to Swift Playgrounds version 3.4 on iPad
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 <private>
, which can be seen on attached screenshot.
While I couldn‘t find a way to modify an Empty/Blank Playground to provide console in-/output. There is the „Answers“ template, that you can use for simple console interactions.
Another way is to use the „Interactions“ template, provided here: https://buildingrainbows.com/2018/03/13/print-to-the-console-in-swift-playgrounds-for-ipad/