You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

iOS中System Search AppIntent/AssistantIntent无法使用排查

iOS 18 Search Intent Siri/Spotlight 失效问题排查与修复

问题代码

@available(iOS 18.0, *)
@AssistantIntent(schema: .system.search)
struct SearchIntent: AppIntent {
  static let title: LocalizedStringResource = "Search <app name redacted>"
  static let searchScopes: [StringSearchScope] = [.general]

  @Parameter(title: "Criteria")
  var criteria: StringSearchCriteria

  @MainActor
  func perform() async throws -> some IntentResult {
    MyDependencyManager.shared.performSearch(with: criteria.term)
    return .result()
  }
}

// In AppShortcutProvider

AppShortcut(
  intent: SearchIntent(),
  phrases: [
   "Find \(\.$criteria) in \(.applicationName)",
    "Search for \(\.$criteria) in \(.applicationName)",
  ],
  shortTitle: "Search <app name redacted>",
  systemImageName: "magnifyingglass"
)

问题描述

该搜索功能在快捷指令App中可正常运行,但通过Siri调用时失效:说出“Search for SOME_THING in MY_APP_NAME”,Siri仅执行谷歌搜索或提示从App Store安装应用(当前为Xcode调试构建版本)。尝试多种语句变体均无效,且不清楚如何在Spotlight中触发该功能。

当前环境:Xcode 16、iPhone 16 Pro(iOS 18.2 beta系统)、已开启Apple Intelligence。


问题排查与修复方案

1. 系统搜索Schema的优先级冲突

使用.system.search系统Schema时,Siri会优先匹配系统级通用搜索,而非应用自定义Intent,尤其是开启Apple Intelligence后,系统对通用搜索的优先级更高。

修复:
改用自定义专属Schema,让Siri明确识别这是应用独有的Intent:

@AssistantIntent(schema: .custom("com.yourcompany.yourapp.search"))

注意自定义Schema标识符需与应用Bundle ID关联,保证唯一性。

2. 调试构建的Siri索引未同步

Xcode调试版本的Intent可能未被Siri正确索引,导致无法识别。

修复:

  • 卸载应用调试版本,重新从Xcode安装;
  • 进入「设置」→「Siri与搜索」→「所有应用」,确认目标应用的「使用Siri」「显示在搜索中」已开启;
  • 重启设备,强制Siri重新索引应用Intent。

3. Spotlight触发配置缺失

当前代码未配置Spotlight关联规则,iOS 18需要额外配置才能让Intent在Spotlight中触发。

修复:
在SearchIntent中添加Spotlight显示名称配置:

static let spotlightDisplayName: LocalizedStringResource = "Search in <app name>"

同时简化AppShortcut的触发短语,Spotlight更易匹配短指令:

phrases: [
  "Search \(\.$criteria)",
  "Find \(\.$criteria) in MyApp"
]

4. 参数匹配精度不足

\(.applicationName)变量可能未被Siri正确关联到调试应用名称,导致指令匹配失败。

修复:
在触发短语中直接使用应用的实际名称,而非变量:

phrases: [
  "Find \(\.$criteria) in MyApp",
  "Search for \(\.$criteria) in MyApp",
]

测试时使用完全匹配的指令,避免Siri模糊匹配到系统搜索。


额外验证步骤

  1. 在快捷指令App中创建个人自动化,触发目标Siri指令,验证Intent本身逻辑是否正常;
  2. 检查Xcode日志(过滤「Siri」「Intent」关键词),排查是否有Intent识别失败的错误信息;
  3. 确认应用的Intent配置(如存在Intent Definition文件)与代码逻辑完全一致。

内容的提问来源于stack exchange,提问作者Suyash Srijan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 21:57:14