If you have read many of my older posts, you will see that I am a fan of automation, and a great way to automate on iOS and now macOS is to use the built-in Shortcuts application. I will go through an issue I found while trying to add custom Shortcuts actions to my iOS application.
I have for a while been considering creating an application that provides a list of actions to Shortcuts to help with everyday tasks. In a previous post, I have discussed how to add Siri Shortcuts in a Xamarin application, but that process requires many extra steps, and with MAUI soon to replace Xamarin, I decided that I might try and write this application in Swift.
This post is not going into detail about how you create these custom Shortcuts actions, so if you would like to learn how to add these (and also not encounter the error I ran into), you should check out the series of blog posts the creator of Toolbox Pro, Alex Hay has put together on their blog.
To set a little bit of context about what is required to create custom Shortcuts actions, Apple needs you to create something called an Intents Extension
, and this extension is just like a separate container with some code that gets run when Shortcuts calls your action. The other concept to mention is for Shortcuts to list the actions you need to create an intentdefinition file that describes your actions.
The error
The error that I encountered after creating the intents extension etc was that even though the application I had made was installed on the device, the custom Shortcuts actions that I had exposed in the intentsdefinition file were not appearing in the list of actions available in the Shortcuts application.
The fix
The issue was the intentdefinition (as described above) was available in the intent extensions that I have created, but I didn't include it in the main application. The fix for this is to ensure that the main application target for the intentsdefintion file in the Target Membership section of the inspector has been checked.