What is an App Intent?

At its heart an App Intent is really simple. It is just a struct that conforms to the protocol AppIntent.

struct SomeIntent : AppIntent { ... }

To conform to the AppIntent protocol we need two things. One is we need a static variable name title that is a LocalizedStringResource.

struct SomeIntent : AppIntent {
    static var title : LocalizedStringResource = "SomeIntentTitle"
}

The other thing we need is a async function named perform that can throw an error and that returns some IntentResult

struct SomeIntent : AppIntent {
    static var title : LocalizedStringResource = "SomeIntentTitle"
    func perform() async throws -> some IntentResult { ... }
}

At its core, the App Intent system is based on a struct that conforms to the AppIntent protocol and is integrated into the system. When used, the perform function is called, and the IntentResult is processed. From here, we can gradually expand on Apple's AppIntent system.

0
Subscribe to my newsletter

Read articles from Nicholas Hartman directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Nicholas Hartman
Nicholas Hartman