WidgetKit Options Provider not called

I'm adding a Widget to an existing iOS app. The Widget's intent definition allows the user to choose the preferred item in configuration. The provideItemOptionsCollection function in IntentsHandler.swift is not called, and I can't figure out why.

I developed the extension inside a dummy app. It works as expected there. I copied the code and intents handler info to the real app. All looks good, other than the user cannot configure the widget. The user gets the No options were provided for this parameter alert when attempting to choose the item.

I've confirmed I'm using the correct function signature, by copying it from Xcode's generated SelectionIntent.swift file. I added an os_log call as the first line in the function, and confirmed it does not appear in the console. I also added an os_log call to the same class's default (unchanged) handler, which does appear in console as expected.

I'm experiencing the same issue on both the Simulator and a physical device. Xcode 12.4, iOS 14.4.

Accepted Reply

I'm a dunce: When copying code from the dummy app, I didn't add the SelectionIntentHandling protocol to the class. Added and all is good.

Replies

I'm a dunce: When copying code from the dummy app, I didn't add the SelectionIntentHandling protocol to the class. Added and all is good.