How to debug iOS 14 widget in Xcode 12?

Since I found no other way to debug the widget extension I wrote a logging method which adds the log output to a a file a the apps group folder:

static func logToFile(_ text: String) {        
    if let documentsDirectory = FileManager().containerURL(forSecurityApplicationGroupIdentifier: "") {
        let logFileUrl = documentsDirectory.appendingPathComponent("log.txt")
        do {
            var logContent = try String(contentsOf: logFileUrl, encoding: .utf8)
            logContent = (logContent.count > 0 ? "\(text)\n\(logContent)" : text)
            try logContent.write(to: logFileUrl, atomically: false, encoding: .utf8)
        catch {}

Not the best solution but the only one I found so far.

Seems Xcode bug here. Quick fix works for me is open log console manually by cmd + shift + y. And also add breakpoints. And then run widget to see logs.

On the top left of Xcode->

  1. Click project name, you can see a list, select widget name, run it
  2. Click widget name, you can see a list, select project name, run it

Xcode: Version 12.3, iPad: iPadOS 14.3
This works for me.

Select your widget target at the top left corner of Xcode, build and run the app, then the widget process will be able to debug and show logs. (This example project is downloaded provided by Apple:

enter image description here