26

From time to time widget crashing with "unable to load" error. Is anyone know how to fix it? Widget haven't requests to server or smth else.

enter image description here

FelixSFD
  • 6,052
  • 10
  • 43
  • 117
Ildar.Z
  • 666
  • 1
  • 7
  • 17

7 Answers7

34

Unable to load in today extension mostly appears when:

  1. You extension crash due to some reason
  2. It takes more memory than what is provided by the system. (Memory Limit : max 16MB approx.)

Debug your app extension to find out the exact problem.

Refer to Xcode's Debug Gauge for Memory and CPU utilization.

Edit:

Debugging today extension

You can debug your extension the same way you debug your main project. Just select that particular target scheme in your Xcode and run the project.

enter image description here

Now try using the breakpoints and other print statements in the extension’s code and you are good to go. Happy coding..

PGDev
  • 23,751
  • 6
  • 34
  • 88
5

REBOOT the device.
This saved me.

ho2103
  • 407
  • 5
  • 6
1

I have faced this error I used a custom view. But forgot to check Is initial viewController. Set an entry point form "show attribute inspector" as an initial view controller

Shourob Datta
  • 1,886
  • 22
  • 30
1
  1. I have faced the same issue where it wasn't showing anything. Even my debug option was not working. I found an article online which helped me a lot. I would like to recommend this here.

  2. Most of the time it is the size of the content view that crashes the widget. in that case, use this code snippet in TodayViewController.

Code snippet

override func viewWillAppear(_ animated: Bool)
{
    var currentSize: CGSize = self.preferredContentSize
    currentSize.height = 200.0
    self.preferredContentSize = currentSize
}                                                                                       

Link for further research.

Dharmesh Mansata
  • 4,422
  • 1
  • 27
  • 33
0

Make sure you have more than 0 rows

I have built a today-widget similar to Building a Simple Widget for the Today View.

I had none of the above issues. Mine was 0 row (I had no data for this particular day and hence, 0 row). I did not expect that it could be the problem since in the main-app, you can have empty table-view.

If you see unable to load message, make sure you have at least 1 row.

mahan
  • 12,366
  • 5
  • 48
  • 83
0

Set this in viewDidLoad:

extensionContext?.widgetLargestAvailableDisplayMode = .expanded
bryanjclark
  • 6,247
  • 2
  • 35
  • 68
Santiago
  • 448
  • 3
  • 12
0

In my case NotificationCenter.framework was accidentally deleted from Link Binary With Libraries in Build Phases tab in widget target.