Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Siri Intents Extension "I don't see an app for that. You'll need to download one."

I am writing a Swift framework that contains a Siri intentdefinition file and code that is used both from the main app, from a Today extension, and from a Siri intent extension. I am using Cocoapods to distribute the framework (it is in a private repo, so I cannot share the framework itself). This works well for compiling, linking, and executing code from within the app and the Today extension.

The app (or Today extension) successfully donates the intent when the user performs the corresponding action. I can then go to System Settings/Siri/Suggested Shortcuts and record a "personalized phrase" to trigger the intent.

When I invoke Siri using the recorded phrase, she responds with "I don't see an app for that. You'll need to download one."

I also noticed the following error message when donating the intent:

[Intents] -[INIntentResponse init] App proxy < com.company.appID file:///Users/username/Library/Developer/CoreSimulator/Devices/.../data/Containers/Bundle/Application/.../AppName.app :0>> doesn't contain intent nameOfIntent, falling back to current bundle

The same code worked fine until I moved it into a framework, so I know the code is correct.

like image 338
Paul King Avatar asked Oct 02 '18 17:10

Paul King


1 Answers

Apparently, the information contained within the intent that is donated is not sufficient for com.apple.notificationcenterui to be able to resolve the correct app to respond to the intent, which I find baffling. In order for the system to find the app successfully, the intentdefinition file must be contained in the app's main bundle. If you are not using Cocoapods, just can just check a box to include the intentdefinition file in the app's bundle, as Apple recommends in their Introduction to Siri Shortcuts WWDC video.

When using Cocoapods, this is problematic, in that the framework and the intentdefinition file are in a separate project within a workspace, so you can't just check a box to include the file in the app's bundle.

To solve this problem when using Cocoapods, I added the following to my app's podfile:

post_install do |installer|
  require 'fileutils'
  # Copy Siri intentdefinition file from framework to app's resource folder, then use "Copy Bundle Resources" phase to copy it into app's main bundle
  FileUtils.cp_r('Pods/FrameworkName/FrameworkName/Base.lproj/Intents.intentdefinition', 'Resources/Intents.intentdefinition', :remove_destination => true)
end
  1. Run pod install
  2. Navigate to your app target's "Build Phases"/"Copy Bundle Resources"
  3. Click the "+" button at the bottom of the list
  4. Click "Add Other..." at the bottom of the prompt
  5. Navigate to your app's "Resources" folder
  6. Select the Intent.intentdefinition file, which should already be in the folder from step #1

Now, each time you pod install or pod update, it will automatically put the latest intentdefinition where the compiler can include it in the app bundle and Siri is happy.

like image 190
Paul King Avatar answered Oct 08 '22 05:10

Paul King