2

I am trying to create an Intents Extension for macOS 12 Monterey.

What I've done:

  • I've created an Intents Definition file and configured a Custom Intent
  • I've created a Handler class that confirms to my Handling protocol that has been created by Xcode using the Intent Definition
  • I've added an Intents Extension as a new target that creates my Handler class in func handler(for intent: INIntent) -> Any

Problem:

My shortcut action does appear in Shortcuts. However, ever time I run a shortcut with my action, the main app launches and not the extension itself.

I've been able to figure out what I was doing wrong, look at my answer below.

Daniel
  • 1,473
  • 3
  • 33
  • 63

1 Answers1

3

I've found two possible causes for this:

  1. Do not add your Intent to Supported Intents of your main app (info.plist) as you only have to do this if you want your main app to handle the intent via func application(_ application: NSApplication, handlerFor intent: INIntent) -> Any?. in the app delegate (a.k.a. in-app handling) - you want your extension to handle the intent
  2. By default Intent Extensions aren't sandboxed. So you have to enable App Sandbox in the build settings and add an entitlements file with com.apple.security.app-sandbox set to true. Apple should really do this for any new Intent Extension by default.
  3. When adding a new target for your Intent Extension, make sure not to select App Intent Extension. enter image description here

Cheers!

Daniel
  • 1,473
  • 3
  • 33
  • 63
  • When I create an Intents extension, I keep getting the following error: "Provisioning profile "Mac Team Provisioning Profile: com.myapp.blah" doesn't include the aps-environment and com.apple.developer.siri entitlements". I've tried adding the entitlements as well, but doesn't help. I have "Automatically Manage Signing" enabled. – Z S Oct 21 '21 at 23:03
  • 1
    After many hours, I finally figured it out. When I created the Intents extension, for *some bizarre reason*, Xcode decided to lift the entitlements from the iOS app's target's entitlements file instead of from the Mac app target. I had to switch them back in build settings, and automatic provisioning works again. – Z S Oct 22 '21 at 05:07
  • Exactly this! I spent several hours trying to figure out why it does not work even though it was listed in shortcuts. I had error "Is your intent listed in IntentsSupported in the extension Info.plist?" - hopefully more people will find your answer - thanks! – Krzysztof Jan 27 '22 at 08:57