App Intent in separate target doesn't work

Made a separate target for App Intents, but I don't get it to work.

The intent is shown in the Shortcuts app when registered using AppShortcutsProvider. But upon running the intent it gives this error:

Error Domain=LNActionFor- AutoShortcutPhraseFetchError Code=1 "No AutoShortcuts instance registered." UserInfo={NSLocalizedDescription=No AutoShortcuts instance registered.}

I've attached a sample project to my FA-post

FB10199299

Post not yet marked as solved Up vote post of JagCesar Down vote post of JagCesar
1.9k views

Replies

I am facing the same issue. Tapping on a shortcut in the shortcuts app under the App Shortcuts section, shows below error:

Error Domain=LNActionFor- AutoShortcutPhraseFetchError Code=1 "No AutoShortcuts instance registered." UserInfo={NSLocalizedDescription=No AutoShortcuts instance registered.}

Here is my code:

struct OpenCurrentlyReading: AppIntent {
    static var title: LocalizedStringResource = "Open Currently Reading"

    func perform() async throws -> some PerformResult {
        return .finished
    }

    static var openAppWhenRun: Bool = true
}

public struct LibraryAppShortcuts: AppShortcutsProvider {
    public static var appShortcuts: [AppShortcut] {
        AppShortcut (
            intent: OpenCurrentlyReading(),
            phrases: ["Open Currently Reading"],
            systemImageName: "books.vertical.fill"
        )

    }
}

@main
struct FoodTruckAppShortcutsExtension: AppIntentsExtension {
}

However, same code is working fine for In-app Intents.

Same problem here. Looks like App Intents are a bit rough in beta 1.

What do you mean by separate target? Your app intents have to be compiled from within the app target to work

  • I don't think that's true. They can be compiled from the app target, but it's not required.

    In our case we have a lightweight Intent Target that fetches data from CoreData and returns what's requested.

  • I'm sorry, my answer was misleading. The intents can be compiled in the app or an intent target but not in a separate package (which you might use for modularization). And even this is not 100% true, you could basically have all the types in a package and add the AppIntent's protocol conformances in the app/intents targets.

Add a Comment

I also reported the issue more than a month ago ( FB10546626 ), but it’s still present in Xcode 14.0 beta 6, and it starts to be a problem:

  • it’s not a minor thing - they released App Intents and App Shortcuts and App Shortcuts don’t work in the extension where it is supposed to work;
  • if it won’t be fixed before the release of iOS 16, we need to migrate from App Intents Extension to in-app App Intents

Found one thing today, if application name included in phrase, it shows app shortcuts in shortcuts app.