4

I am trying to make a WidgetKit widget for macOS Big Sur. The widget itself works -- the same code on both the Mac and iOS. The issue is that on the Mac the intent (settings) does not work. When I click "Edit Widget" the options I defined do not appear. When I press "Done," it's replaced with a screen that says "Unable to load."

This seems to happen with a brand new target and just a simple new text parameter. These are the steps I took:

  1. Create a new Mac project
  2. Add a new Widget target
  3. Change the generated Intent, adding a parameter. You also need to add a "Siri Dialog Prompt"
  4. Click "Run"
  5. Click "Info" in the Widget Simulator
  6. Click "Configure Intent"

Am I missing something or is this a bug?

This has been an issue since at least Big Sur beta 5 and Xcode 12b6. I opened a ticket with Apple, but I'm also asking here as it seems that some people have it working and it's entirely possible that I'm missing something!

Stephen Darlington
  • 51,577
  • 12
  • 107
  • 152

2 Answers2

3

This seems to be a bug of the Widget Simulator. When I run the same Widget in the Widget panel of Big Sur, I see all configuration options.

Ely
  • 8,259
  • 1
  • 54
  • 67
  • Are you doing something different to me? I get the same behaviour in the simulator and the notification center. – Stephen Darlington Nov 02 '20 at 10:18
  • 4
    Make sure that you add the Sandbox entitlement to the Widget project. This article https://www.rambo.codes/posts/2020-09-08-creating-configurable-widgets-for-macos-big-sur (and the referred Git project) that I found today may contain some additional useful info and clues. – Ely Nov 02 '20 at 12:06
  • @Ely Your comment savesd me. I have to add Sandbox entitlement not only to Widget extension but to IntentHandler as well. – Kamil Powałowski Nov 22 '20 at 13:06
3

The problem turned out to be an older copy of the app on my disk and macOS getting confused and looking in the wrong place.

I'm adding a Widget to an existing app that doesn't currently have one. I have the current, App Store version in /Applications. I've been running the updated version from Xcode or exporting it to my desktop and running it from there. The Widget itself -- as noted in the question -- runs just fine. But it seems that when looking for the Intent used for the configuration, it prefers to look in /Application rather than the Xcode version. As soon as I deleted the original app, the widget and its settings immediately started working.

Thanks to Ely for pointing me to this blog which didn't give the answer but pointing me in the right direction.

Stephen Darlington
  • 51,577
  • 12
  • 107
  • 152