View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Vidéos

Ouvrir le menu Fermer le menu
  • Collections
  • Toutes les vidéos
  • À propos

Plus de vidéos

  • À propos
  • Code
  • Dive into App Intents

    Learn how you can make your app more discoverable and increase app engagement when you use the App Intents framework. We'll take you through the powerful capabilities of this Swift framework, explore the differences between App Intents and SiriKit Intents, and show you how you can expose your app's functionality to the system. We'll also share how you can build entities and queries to create rich App Shortcuts experiences.

    To learn more about App Intents, watch "Implement App Shortcuts with App Intents" and "Design App Shortcuts" from WWDC22.

    Ressources

    • App Intents
      • Vidéo HD
      • Vidéo SD

    Vidéos connexes

    WWDC23

    • Bring widgets to life

    Tech Talks

    • Migrate custom intents to App Intents
    • What's new for enterprise developers

    WWDC22

    • Design App Shortcuts
    • Implement App Shortcuts with App Intents
    • Meet Focus filters

    WWDC21

    • Design great actions for Shortcuts, Siri, and Suggestions
  • Rechercher dans cette vidéo…
    • 5:33 - Open Currently Reading

      struct OpenCurrentlyReading: AppIntent {
          static var title: LocalizedStringResource = "Open Currently Reading"
      
          @MainActor
          func perform() async throws -> some IntentResult {
              Navigator.shared.openShelf(.currentlyReading)
              return .result()
          }
        
          static var openAppWhenRun: Bool = true
      }
    • 6:42 - App Shortcuts

      struct LibraryAppShortcuts: AppShortcutsProvider {
          static var appShortcuts: [AppShortcut] {
              AppShortcut(
                  intent: OpenCurrentlyReading(),
                  phrases: ["Open Currently Reading in \(.applicationName)"],
                  systemImageName: "books.vertical.fill"
              )
          }
      }
    • 7:11 - Shelf Enum

      enum Shelf: String {
          case currentlyReading
          case wantToRead
          case read
      }
      
      extension Shelf: AppEnum {
          static var typeDisplayRepresentation: TypeDisplayRepresentation = "Shelf"
      
          static var caseDisplayRepresentations: [Shelf: DisplayRepresentation] = [
              .currentlyReading: "Currently Reading",
              .wantToRead: "Want to Read",
              .read: "Read",
          ]
      }
    • 7:49 - Open Shelf

      struct OpenShelf: AppIntent {
          static var title: LocalizedStringResource = "Open Shelf"
      
          @Parameter(title: "Shelf")
          var shelf: Shelf
      
          @MainActor
          func perform() async throws -> some IntentResult {
              Navigator.shared.openShelf(shelf)
              return .result()
          }
      
          static var parameterSummary: some ParameterSummary {
              Summary("Open \(\.$shelf)")
          }
      
          static var openAppWhenRun: Bool = true
      }
    • 10:56 - Book Entity

      struct BookEntity: AppEntity, Identifiable {
          var id: UUID
      
          var displayRepresentation: DisplayRepresentation { "\(title)" }
      
          static var typeDisplayRepresentation: TypeDisplayRepresentation = "Book"
      
          static var defaultQuery = BookQuery()
      }
    • 12:29 - Book Query

      struct BookQuery: EntityQuery {
          func entities(for identifiers: [UUID]) async throws -> [BookEntity] {
              identifiers.compactMap { identifier in
                  Database.shared.book(for: identifier)
              }
          }
      }
    • 13:16 - Open Book

      struct OpenBook: AppIntent {
          @Parameter(title: "Book")
          var book: BookEntity
      
          static var title: LocalizedStringResource = "Open Book"
      
          static var openAppWhenRun = true
      
          @MainActor
          func perform() async throws -> some IntentResult {
              guard try await $book.requestConfirmation(for: book, dialog: "Are you sure you want to clear read state for \(book)?") else {
                  return .result()
              }
              Navigator.shared.openBook(book)
              return .result()
          }
      
          static var parameterSummary: some ParameterSummary {
              Summary("Open \(\.$book)")
          }
        
          init() {}
      
          init(book: BookEntity) {
              self.book = book
          }
      }
    • 13:40 - Suggested Entities and String Book Query

      struct BookQuery: EntityStringQuery {
          func entities(for identifiers: [UUID]) async throws -> [BookEntity] {
              identifiers.compactMap { identifier in
                  Database.shared.book(for: identifier)
              }
          }
      
          func suggestedEntities() async throws -> [BookEntity] {
              Database.shared.books
          }
      
          func entities(matching string: String) async throws -> [BookEntity] {
              Database.shared.books.filter { book in
                  book.title.lowercased().contains(string.lowercased())
              }
          }
      }
    • 15:11 - Add Book Intent

      struct AddBook: AppIntent {
          static var title: LocalizedStringResource = "Add Book"
      
          @Parameter(title: "Title")
          var title: String
      
          @Parameter(title: "Author Name")
          var authorName: String?
      
          @Parameter(title: "Recommended By")
          var recommendedBy: String?
      
          func perform() async throws -> some IntentResult & ReturnsValue<BookEntity> & OpensIntent {
              guard var book = await BooksAPI.shared.findBooks(named: title, author: authorName).first else {
                  throw Error.notFound
              }
              book.recommendedBy = recommendedBy
              Database.shared.add(book: book)
      
              return .result(
                  value: book,
                  openIntent: OpenBook(book: book)
              )
          }
      
          enum Error: Swift.Error, CustomLocalizedStringResourceConvertible {
              case notFound
      
              var localizedStringResource: LocalizedStringResource {
                  switch self {
                      case .notFound: return "Book Not Found"
                  }
              }
          }
      }
    • 18:21 - Book Entity with Properties

      struct BookEntity: AppEntity, Identifiable {
          var id: UUID
      
          @Property(title: "Title")
          var title: String
      
          @Property(title: "Publishing Date")
          var datePublished: Date
      
          @Property(title: "Read Date")
          var dateRead: Date?
      
          var recommendedBy: String?
      
          var displayRepresentation: DisplayRepresentation { "\(title)" }
      
          static var typeDisplayRepresentation: TypeDisplayRepresentation = "Book"
      
          static var defaultQuery = BookQuery()
      
          init(id: UUID) {
              self.id = id
          }
      
          init(id: UUID, title: String) {
              self.id = id
              self.title = title
          }
      }
    • 20:59 - Books Property Query

      struct BookQuery: EntityPropertyQuery {
          static var sortingOptions = SortingOptions {
              SortableBy(\BookEntity.$title)
              SortableBy(\BookEntity.$dateRead)
              SortableBy(\BookEntity.$datePublished)
          }
      
          static var properties = QueryProperties {
              Property(\BookEntity.$title) {
                  EqualToComparator { NSPredicate(format: "title = %@", $0) }
                  ContainsComparator { NSPredicate(format: "title CONTAINS %@", $0) }
              }
              Property(\BookEntity.$datePublished) {
                  LessThanComparator { NSPredicate(format: "datePublished < %@", $0 as NSDate) }
                  GreaterThanComparator { NSPredicate(format: "datePublished > %@", $0 as NSDate) }
              }
              Property(\BookEntity.$dateRead) {
                  LessThanComparator { NSPredicate(format: "dateRead < %@", $0 as NSDate) }
                  GreaterThanComparator { NSPredicate(format: "dateRead > %@", $0 as NSDate) }
              }
          }
      
          func entities(for identifiers: [UUID]) async throws -> [BookEntity] {
              identifiers.compactMap { identifier in
                  Database.shared.book(for: identifier)
              }
          }
      
          func suggestedEntities() async throws -> [BookEntity] {
              Model.shared.library.books.map { BookEntity(id: $0.id, title: $0.title) }
          }
      
          func entities(matching string: String) async throws -> [BookEntity] {
              Database.shared.books.filter { book in
                  book.title.lowercased().contains(string.lowercased())
              }
          }
      
          func entities(
              matching comparators: [NSPredicate],
              mode: ComparatorMode,
              sortedBy: [Sort<BookEntity>],
              limit: Int?
          ) async throws -> [BookEntity] {
              Database.shared.findBooks(matching: comparators, matchAll: mode == .and, sorts: sortedBy.map { (keyPath: $0.by, ascending: $0.order == .ascending) })
          }
      }
    • 24:10 - Dialog

      struct AddBook: AppIntent {
          static var title: LocalizedStringResource = "Add Book"
      
          @Parameter(title: "Title")
          var title: String
      
          @Parameter(title: "Author Name")
          var authorName: String?
      
          @Parameter(title: "Recommended By")
          var recommendedBy: String?
      
          func perform() async throws -> some IntentResult & ReturnsValue<BookEntity> & ProvidesDialog {
              guard var book = await BooksAPI.shared.findBooks(named: title, author: authorName).first else {
                  throw Error.notFound
              }
              book.recommendedBy = recommendedBy
              Database.shared.add(book: book)
      
              return .result(
                  value: book,
                  dialog:"Added \(book) to Library!"
              )
          }
      
          enum Error: Swift.Error, CustomLocalizedStringResourceConvertible {
              case notFound
      
              var localizedStringResource: LocalizedStringResource {
                  switch self {
                      case .notFound: return "Book Not Found"
                  }
              }
          }
      }
    • 24:25 - Snippet

      struct AddBook: AppIntent {
          static var title: LocalizedStringResource = "Add Book"
      
          @Parameter(title: "Title")
          var title: String
      
          @Parameter(title: "Author Name")
          var authorName: String?
      
          @Parameter(title: "Recommended By")
          var recommendedBy: String?
      
          func perform() async throws -> some IntentResult & ShowsSnippetView {
              guard var book = await BooksAPI.shared.findBooks(named: title, author: authorName).first else {
                  throw Error.notFound
              }
              book.recommendedBy = recommendedBy
              Database.shared.add(book: book)
      
              return .result(value: book) {
                  CoverView(book: book)
              }
          }
      
          enum Error: Swift.Error, CustomLocalizedStringResourceConvertible {
              case notFound
      
              var localizedStringResource: LocalizedStringResource {
                  switch self {
                      case .notFound: return "Book Not Found"
                  }
              }
          }
      }
    • 24:50 - Request Value

      struct AddBook: AppIntent {
          static var title: LocalizedStringResource = "Add Book"
      
          @Parameter(title: "Title")
          var title: String
      
          @Parameter(title: "Author Name")
          var authorName: String?
      
          @Parameter(title: "Recommended By")
          var recommendedBy: String?
      
          func perform() async throws -> some IntentResult {
              let books = await BooksAPI.shared.findBooks(named: title, author: authorName)
              guard !books.isEmpty else {
                  throw Error.notFound
              }
              if books.count > 1 && authorName == nil {
                  throw $authorName.requestValue("Who wrote the book?")
              }
      
              return .result()
          }
      
          enum Error: Swift.Error, CustomLocalizedStringResourceConvertible {
              case notFound
      
              var localizedStringResource: LocalizedStringResource {
                  switch self {
                      case .notFound: return "Book Not Found"
                  }
              }
          }
      }
    • 25:22 - Request Disambiguation

      struct AddBook: AppIntent {
          static var title: LocalizedStringResource = "Add Book"
      
          @Parameter(title: "Title")
          var title: String
      
          @Parameter(title: "Author Name")
          var authorName: String?
      
          @Parameter(title: "Recommended By")
          var recommendedBy: String?
      
          func perform() async throws -> some IntentResult {
              let books = await BooksAPI.shared.findBooks(named: title, author: authorName)
              guard !books.isEmpty else {
                  throw Error.notFound
              }
              if books.count > 1 {
                  let chosenAuthor = try await $authorName.requestDisambiguation(among: books.map { $0.authorName }, dialog: "Which author?")
              }
              return .result()
          }
      
          enum Error: Swift.Error, CustomLocalizedStringResourceConvertible {
              case notFound
      
              var localizedStringResource: LocalizedStringResource {
                  switch self {
                      case .notFound: return "Book Not Found"
                  }
              }
          }
      }
    • 25:48 - Request Parameter Confirmation

      struct AddBook: AppIntent {
          static var title: LocalizedStringResource = "Add Book"
      
          @Parameter(title: "Title")
          var title: String
      
          @Parameter(title: "Author Name")
          var authorName: String?
      
          @Parameter(title: "Recommended By")
          var recommendedBy: String?
      
          func perform() async throws -> some IntentResult & ReturnsValue<BookEntity> {
              guard var book = await BooksAPI.shared.findBooks(named: title, author: authorName).first else {
                  throw Error.notFound
              }
              let confirmed = try await $title.requestConfirmation(for: book.title, dialog: "Did you mean \(book)?")
              book.recommendedBy = recommendedBy
              Database.shared.add(book: book)
              return .result(value: book)
          }
      
          enum Error: Swift.Error, CustomLocalizedStringResourceConvertible {
              case notFound
      
              var localizedStringResource: LocalizedStringResource {
                  switch self {
                      case .notFound: return "Book Not Found"
                  }
              }
          }
      }
    • 26:26 - Request Result Confirmation

      struct BuyBook: AppIntent {
          @Parameter(title: "Book")
          var book: BookEntity
      
          @Parameter(title: "Count")
          var count: Int
      
          static var title: LocalizedStringResource = "Buy Book"
      
          func perform() async throws -> some IntentResult & ShowsSnippetView & ProvidesDialog {
              let order = OrderEntity(book: book, count: count)
              try await requestConfirmation(output: .result(value: order, dialog: "Are you ready to order?") {
                  OrderPreview(order: order)
              })
      
              return .result(value: order, dialog: "Thank you for your order!") {
                  OrderConfirmation(order: order)
              }
          }
      }

Developer Footer

  • Vidéos
  • WWDC22
  • Dive into App Intents
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines