iOS Siri Intents Extension”我没有看到用于此目的的应用程序。您需要下载一个。” [英] iOS Siri Intents Extension "I don't see an app for that. You'll need to download one."

查看:194
本文介绍了iOS Siri Intents Extension”我没有看到用于此目的的应用程序。您需要下载一个。”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个Swift框架,其中包含一个Siri intentdefinition文件和从主应用程序,Today扩展和Siri intent扩展中使用的代码。我正在使用Cocoapods分发框架(它在一个私有仓库中,所以我不能共享框架本身)。

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.

该应用程序(或Today扩展程序)在用户执行时成功捐赠了意图,这在从应用程序和Today扩展程序中编译,链接和执行代码时非常有效。相应的动作。然后,我可以转到系统设置 / Siri /建议的快捷方式并记录一个个性化短语以触发意图。

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.

当我使用录制的短语调用Siri时,她的回答是我没有看到相应的应用。您需要下载一个。

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:


[意图]- [INIntentResponse初始化]应用程序代理< com.company.appID
文件:///Users/username/Library/Developer/CoreSimulator/Devices/.../data/Containers/Bundle/Application/.../AppName.app
: 0 >>不包含意图
nameOfIntent,回落到当前捆绑包中

[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.

推荐答案

显然,捐赠意图中包含的信息是不足以使com.apple.notificationcenterui能够解析正确的应用程序以响应该意图,我对此感到困惑。为了使系统成功找到该应用,intentdefinition文件必须包含在该应用的主捆绑包中。如果您不使用Cocoapods,只需按照Apple在其 Siri快捷方式WWDC视频简介

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.

在使用Cocoapods时,这是有问题的,因为该框架和intentdefinition文件位于工作空间中的一个单独项目中,因此您不能仅选中一个复选框以将该文件包含在应用程序的捆绑包中。

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.

要解决此问题使用Cocoapods时,我在应用程序的podfile中添加了以下内容:

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. 运行 pod安装

  2. 导航到您的应用目标的构建阶段 /复制捆绑包资源

  3. 单击列表底部的 +按钮

  4. 单击添加其他。提示底部的 ..

  5. 导航到应用程序的资源文件夹

  6. 选择Intent.intentdefinition文件,该文件应该已经在步骤#1的文件夹中

  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

现在,每次您 pod安装 pod更新,它将自动将最新的intentdefinition放在编译器可以将其包含在应用程序中的位置b松开,Siri很高兴。

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.

这篇关于iOS Siri Intents Extension”我没有看到用于此目的的应用程序。您需要下载一个。”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆