Ildar.Z
Ildar.Z

Reputation: 656

Today-Widget "Unable to load" error

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

Upvotes: 26

Views: 13737

Answers (7)

Volodymyr Smolianinov
Volodymyr Smolianinov

Reputation: 183

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

Upvotes: 0

Huifeng Ou
Huifeng Ou

Reputation: 447

REBOOT the device.
This saved me.

Upvotes: 6

Santiago
Santiago

Reputation: 588

Set this in viewDidLoad:

extensionContext?.widgetLargestAvailableDisplayMode = .expanded

Upvotes: 0

mahan
mahan

Reputation: 14925

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.

Upvotes: 0

MALIKK HABIB UR REHMAN
MALIKK HABIB UR REHMAN

Reputation: 880

  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.

Upvotes: 1

PGDev
PGDev

Reputation: 24341

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..😊

Upvotes: 34

Shourob Datta
Shourob Datta

Reputation: 2072

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

Upvotes: 1

Related Questions