iOS 10: How to debug a Today Widget - "Unable to load" message
Asked Answered
C

2

30

It seems to me that whenever a Today Widget crashes for any reason it displays the "Unable to load" message (as on the attached screen).

When this happens nothing kicks off in the debugger, nothing appears on the Console. It seems to me like searching for a needle in the haystack. Is it possibl to debug the "Unable to load" message in Xcode in any way?

Xcode version: 8.2

iOS Simulator: 10.2

Unable to load

Chara answered 27/12, 2016 at 15:23 Comment(1)
Same issue here :(Eadmund
T
26

You can debug you Today Extension by doing the following:

With the application running in your device/simulator, open the widget. Then, when you have your widget open, go to Xcode->Debug->Attach to Process and you should find your widget name.

Note this will only work if you have your widget opened. You can set breakpoints and debug step by step to find out why the "Unable to Load" message appears.

Thane answered 16/2, 2017 at 13:30 Comment(3)
I am able to use os_log for my extensions to console, for all extensions except today widget. Edit: this is without attaching to a process or having Xcode running.Engedus
Hey i can't find my widget name there. what should i do now ? Thank YouSerrated
Was able to get some console logs by long-pressing the launching app icon to make the widget appear.Goldin
B
0

You can simply select the widget's target in XCode and just run the project, and debug it as usual, with breakpoints, etc.

XCode selecting the widget's target

There is a catch: if the widget is already showing "Unable to load", then it means it crashed, and the debugging won't work.

What I found to be consistently working in restarting the widget is changing the device's language.

So, go to Settings -> General -> Change language

Then run your widget's target from XCode on that phone. Wait until the widgets page shows up and scroll down until your widget appears on the screen (that is when the widget gets loaded). Even if it crashes now, you will see the crash in XCode.

Bluepoint answered 14/1, 2022 at 14:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.