我想在Swift 2.3版本的基础上,将Siri/Intent扩展集成到我的App中。我正在使用Xcode 8 beta 6构建。但是该应用程序甚至无法编译,并输出错误消息,如下所示:“Type 'IntentHandler' does not conform to protocol 'INSendMessageIntentHandling'。” “Protocol requires function 'handle(sendMessage:completion:)' with type '(sendMessage: INSendMessageIntent, completion: (INSendMessageIntentResponse) -> Void) -> Void'”。而且,“Objective-C method 'handleWithSendMessage:completion:' provided by method 'handle(sendMessage:completion:)' does not match the requirement's selector ('handleSendMessage:completion:')”。即使是苹果公司提供的样例应用程序UnicornChat也有同样的问题。我已经将SWIFT_VERSION标志更改为“Yes”,以支持Swift 2.3。以下是代码示例:
func handle(sendMessage intent: INSendMessageIntent, completion: (INSendMessageIntentResponse) -> Void) {
let userActivity = NSUserActivity(activityType: NSStringFromClass(INSendMessageIntent.self))
let response = INSendMessageIntentResponse(code: .Success, userActivity: userActivity)
completion(response)
}
出现了上述错误,操作失败。
有人知道如何在Swift 2.3中使Siri正常工作吗?