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

为何带参数的App Shortcut在Shortcuts中不显示?移除参数则正常

iOS App Shortcuts 参数关联后不显示问题排查

可能的原因及解决方案:

  1. 参数未配置本地化支持
    App Shortcuts 依赖本地化字符串解析参数引用,直接给@Parameter的title传硬编码字符串会导致系统无法正确识别参数。需将参数标题改为LocalizedStringResource类型:

    struct ConnectIntent: AppIntent {
        static var title: LocalizedStringResource = "Call"
        
        // 改用本地化资源作为参数标题
        @Parameter(title: LocalizedStringResource("name"))
        var name: String
        
        // 添加参数摘要,帮助系统理解参数用途
        static var parameterSummary: some ParameterSummary {
            Summary("Call \(\.$name)")
        }
        
        func perform() async throws -> some IntentResult & ProvidesDialog {
            try await CallerService.shared.call(selectedName: name)
            return .result(dialog: "Calling now")
        }
    }
    
  2. 短语未配置本地化
    快捷指令短语建议使用LocalizedStringResource包裹,确保系统能正确解析参数占位符:

    class AppShortcuts: AppShortcutsProvider {
        static var appShortcuts: [AppShortcut] {
            AppShortcut(
                intent: ConnectIntent(),
                phrases: [
                    LocalizedStringResource("Call \(\.$name) in \(.applicationName)")
                ],
                shortTitle: "Call",
                systemImageName: "sparkles"
            )
        }
    }
    
  3. 系统缓存或编译问题

    • 清理Xcode缓存(Cmd+Shift+K)后重新编译安装App
    • 删除设备上的Shortcuts应用缓存(重启设备或重新添加快捷指令)
  4. Intent参数缺少必要配置
    如果参数需要用户输入或选择,需提供参数建议选项,让系统确认快捷指令可被触发:

    // 在ConnectIntent中添加参数建议
    static var parameterSummary: some ParameterSummary {
        Summary("Call \(\.$name)")
    }
    
    // 可选:添加动态参数建议
    func suggestions(for parameter: Parameter<Self>) async throws -> [String] {
        if parameter == \.name {
            return ["Alice", "Bob", "Charlie"]
        }
        return []
    }
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.14 01:23:09