Why can't i see my widget logs on device?

Hi, i have a separate question for the same widget here, so please look there for the source code.

In the widget, you can see i have various print()-calls in the methods. On the simulator i can see the calls, however when i run on my phone, they are not visible anywhere. In xcode the log window closes (and opens up again if i run the app itself, not the extension), and i cannot find them in the console app either.

Is this expected behavior or am i missing something? Thankful for pointers.

Replies

Xcode 14.1 known issue:

Xcode 14.1 release notes seems to mention a known issue

After Running a widget extension, users will need to manually start the debugging session with Debug -> Attach to Process. (99285608)

Approach (works on simulator and device)

  • Run app target and widget target at the same time
  • Attach debugger to your widget

Steps

  1. Select app scheme and run on iOS device (don't stop)
  2. Select widget scheme and run on iOS (don't stop)
    • So both the targets are running at the same time
  3. Select widget scheme then Debug > Attach to Process > Select your widget target name
  4. On device / simulator add widget

Note:

  • You need to attach the debugger every time you run (Xcode forgets debugger added for the previous run)

Now your breakpoints should work as expected and you can debug

For myself, I was not able to get the process newbee outlined to work. Till issue is resolved, I have installed and used the iOS 16.0 simulator in Xcode 14.1 and it works as expected.

Mathias - since it is working in simulator and not device, is it possible your simulator is iOS 16.0 and your device is iOS 16.1?