macoswidgetkitmacos-big-sur

WidgetKit on Mac with Intent doesn't work


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!


Solution

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