App Intent Not Appearing in Shortcuts App

I'm on Xcode 14.2 and running iOS 16.2 on my device (No betas). The intent does not appear in the shortcuts App.

Here's my code..


import AppIntents

@available(iOS 16.0, *)
struct ShowRecentOrder: AppIntent {
  static var title: LocalizedStringResource = "Show my orders"
  static var description = IntentDescription("Shows list of orders")

  @MainActor
  func perform() async throws -> some IntentResult & ProvidesDialog {
    let total = await getRecentOrder()
    let dialog = IntentDialog(total)
    return .result(dialog: dialog)
  }

  private func getRecentOrder() async -> LocalizedStringResource {
    let result = await OrderServiceMock.fetchRecentOrder()
    return LocalizedStringResource(stringLiteral: String(format: "%2.f", result))
  }
}

@available(iOS 16.0, *)
struct ShortcutsService: AppShortcutsProvider {
  // Maximum of 10 App Shortcuts supported by Apple
  @AppShortcutsBuilder static var appShortcuts: [AppShortcut] {
    AppShortcut(
      intent: ShowRecentOrder(),
      phrases: [
        "Show my recent order in \(.applicationName)",
        "View my recent order in \(.applicationName)"
      ]
    )
  }
  static var shortcutTileColor: ShortcutTileColor { .tangerine }
}

class OrderServiceMock {
  static func fetchRecentOrder() async -> String {
    let mockOrders = ["Order 1", "order 2", "Order 3"]
    return mockOrders.randomElement() ?? ""
  }
}
Post not yet marked as solved Up vote post of Subhanc Down vote post of Subhanc
1.4k views
  • Did find a solution ?

Add a Comment

Replies

Yes. The file was not added to the right target under Target Membership

The file was not added to the right target under Target Membership

And that correct target is.....?