How Can I Debug With WidgetKit Extension?

When I develop My WidgetKit Extension,I set some breakpoints for my code In the App Target And Extension Target ,It don't work,Who can help me solve this problem? Thank you!
Answered by Engineer in 800813022

If you need a deeper level of debugging that what is offered in Xcode while running your extension target, Widget Simulator or SwiftUI previews, you can use Console.app to monitor to the relevant processes related to your app and extensions.

A good way to start would be with filtering by the BundleID of the target and / or the target name itself (the process name).

Also be sure to check the system processes for additional information. This will vary based on what and where you are looking but some examples:
To debug APNS you'll want to monitor apnd along with other relevant processes.
To debug WidgetKit, LiveActivities, Dynamic Island you'll want to monitor springboardd, liveactivitiesd along with other relevant processes.

Rico
WWDR - DTS - Software Engineer

Accepted Answer
Have you tried running the extension scheme?
you can also click on debug menu -> attach to process
Thank you for everyone!
I have solved this problem after updating my Xcode, maybe this is the bug of Xcode 12 Bate 2.

If Updating Don't work, do the setup below:
  1. running the extension scheme

  2. click on debug menu -> attach to process

I was running the extension scheme and still not seeing breakpoints or print statements. I got it to work by having the widget extension running, and then running the application scheme.

If you need a deeper level of debugging that what is offered in Xcode while running your extension target, Widget Simulator or SwiftUI previews, you can use Console.app to monitor to the relevant processes related to your app and extensions.

A good way to start would be with filtering by the BundleID of the target and / or the target name itself (the process name).

Also be sure to check the system processes for additional information. This will vary based on what and where you are looking but some examples:
To debug APNS you'll want to monitor apnd along with other relevant processes.
To debug WidgetKit, LiveActivities, Dynamic Island you'll want to monitor springboardd, liveactivitiesd along with other relevant processes.

Rico
WWDR - DTS - Software Engineer

How Can I Debug With WidgetKit Extension?
 
 
Q