This new release adds a bit of polish and begins the integration of Siri Shortcuts with actions. Note that there’s a code-breaking change that requires a simple search-and-replace as we changed the name of a type.
We have exciting work underway to make it easy to make Actions that implement Siri Intents, reusing the Flint Action
model to provide all the smarts around permissions, purchases and conditional features work seamlessly within app extensions. This release starts with the basics while we work out the how to integrate Apple’s Intents framework without forcing all apps using Flint to link against it. It’s surprisingly tricky in part because of Swift’s current limitations around Protocols with Associated Types.
Please note we have a newsletter mailing list for those of you wishing to stay up to date with Flint as it evolves.
Siri Shortcuts support for Actions that are published by Flint as activities
New in this release is the ability to define a suggested invocation phrase for your actions when Flint automatically registers them as an NSUserActivity
.
There is a new convention property for this on Action
:
var suggestedInvocationPhrase: String?
Providing a value for this property and including .prediction
in the Action’s activityTypes
property will add your action to Siri’s predictions as well as make it available as a custom voice shortcut — as well as a shortcut for use in workflows within the Shortcuts app.
If your action already supports URL Routes or its input supports ActivityCodable
, there is nothing more to do! Your shortcut will automatically be dispatched to your action if the user adds it to a Shortcut they create with the Shortcuts app, or if they use the Settings app to add a voice shortcut for it.
There is also a new addVoiceShortcut
convenience function on all action bindings that will bring up the Siri “Add Voice Shortcut” UI to enable the user to create a new voice shortcut based on a specific input to your action.
For more details and advanced usage including customising the suggested phrase based on the input to the action, see the new Siri Shortcuts guide
The Action
protocol now has subtype UIAction
and you should use that
A new protocol UIAction
extends Action
and provides defaults for the queue
and session
properties of action implementations that operate on the main queue and main action session.
Most UI activity occurs on the main queue and within the main ActionSession
for logging purposes, so this convenience means that your UI actions will only be called on the main queue automatically.
Just change all your actions to conform to UIAction
instead of Action
. You will get compile errors if you do not do this as the queue
and session
properties no longer have default values on Action
.
This usage of Swift protocol extensions makes it possible to supply these defaults for different kinds of actions. In future we will have IntentAction
for Siri Intent implementations.
Extension safe APIs
Because Flint is intended to be used throughout apps and on all Apple platforms, including in iOS and watchOS extensions, the framework now compiles with the Extension Safe APIs compiler option enabled.
“Look! No dependencies”
The sole dependency Flint previously had was the handy ZIPFoundation
framework for easily zipping files — used in the code to gather your app’s Flint report and log zips into one file for easy sharing. Why this is something that remains so painful to do on Apple platforms in this modern era is a good question, but for now we’ve “inlined” small portions of that framework we required and removed the dependency.