Nor*_*rik 9 ios ios16 appintents
我正在尝试测试当前 iOS16 Beta 上的新 AppIntents API。查看文档,实现似乎非常简单,但实现后,我在快捷方式应用程序中没有看到我的 AppIntent。该设备运行的是 iOS 16.0。
这就是我实现 AppIntent 的方式:
import AppIntents
struct DoSomethingIntent: AppIntent {
static var title: LocalizedStringResource = "This will do something"
static var description = IntentDescription("Does something")
func perform() async throws -> some PerformResult {
return .finished(value: "Done")
}
}
Run Code Online (Sandbox Code Playgroud)
根据文档,快捷方式应用程序应该能够在安装我的应用程序后找到我的 AppIntent,但我发现情况并非如此。有谁知道我的实施缺少什么?
jma*_*nso 11
AppIntents API 有点新,有奇怪的行为,而且文档也很差。
就我而言,我可以通过将\(.applicationName)参数添加到短语来使它们工作。尝试这个:
struct LibraryAppShorcuts: AppShortcutsProvider {
@AppShortcutsBuilder static var appShortcuts: [AppShortcut] {
AppShortcut(intent: DoSomethingIntent(), phrases: ["Do something with \(.applicationName)"])
}
}
Run Code Online (Sandbox Code Playgroud)
首先你需要通过 xcode-select 选择你的 Xcode-beta.app
清理派生数据
杀死你的应用程序和快捷方式应用程序
在代码中添加快捷方式库
struct LibraryAppShorcuts: AppShortcutsProvider {
@AppShortcutsBuilder static var appShortcuts: [AppShortcut] {
AppShortcut(intent: DoSomethingIntent(), phrases: ["My something phrase"])
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2490 次 |
| 最近记录: |