WidgetKit on macOS with Intent?

Has anyone been able to get a Widget with an intent working on macOS? I have the widget itself working just fine, but when I click "Edit Widget" the options I defined do not appear and the "Done" button doesn't work.

This seems to happen with a brand new target and just a simple new text parameter.

Am I missing something or is this a bug?

I'm using Big Sur beta 6 and Xcode 12b6. This was also the case with Big Sur beta 5.

Accepted Reply

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.

Replies

I can confirm that this still exist on beta 8. Xcode 12.2b1
Works. Need to add intent handler target to Mac OS as well.
This is still not working for me. Clearly I'm doing something different to Hiren, so to be clear, here are the steps:
  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"

I don't see my optional parameter. When I click "Done" it says "Unable to Load."

Back in my main project, the exact same Intent and Widget works just fine on iOS and iPadOS. Is there an extra step for the Mac? Is there a bug? I'm running Big Sur b9 and Xcode 12.2b2 now.
Widget simulator does not work
  1. Add widget (Notification Center or today widget view, not sure what it called. When you tap on top right corner, it allows to add widget of reminders, weather. It will show all Mac apps which has support for widgets)

  2. Right click on widget, it will show edit widget option.

Tested with latest beta Xcode 12.2 beta 2 and it works.
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.
I am on the latest macOS Big Sur 11.2 RC and XCode 12.4 RC. It seems the bug returns.

The Intent of the Widget fails to load when I export the app in XCode through Archive -> Distribute App -> Copy App.
I am sure that I have cleaned up everything in /Applications and XCode's Build Folder.

It works in Widget Simulator and XCode Build and Run though. But it gives me no confident to submit to App Store in this situation.

May anyone please confirm the Intent situation when exported to an app?


Reply to my own post : I am on macOS Big Sur 11.2 RC 3 and XCode 12.4 Release

I can confirm that the Intent exported in the main app only runs when the main app situations in /Applications

I can also confirm that when we click "Run" in XCode, the Widget in the gallery will call the Intent inside XCode/DerivedData

This causes confusion the version of Intent being called in the gallery.

Therefore when I test the export of the main app,
1) I export the app in XCode through Archive -> Distribute App -> Copy App
2) Clean up the Project Build Folder in XCode
3) Move the exported app to /Applications, but do not launch it yet
4) Open Widget Gallery. Make sure the Widget is absent in the first place
5) (Extra) If the Widget still sticks inside the gallery, I will do a spotlight search to eliminate any possible old versions of the Widget. In some occasions, I even have to reboot to make it disappear.
6) Launch the exported app in /Applications. The Intent will be the version in /Applications