2016-09-23 79 views
2

我试图导入WatchOS的SpeechKit框架并收到一个错误。有没有办法与手表一起使用?我得到一个错误,当我导入Speechkit框架说:“没有这样的模块讲话”WatchOS 3是否支持SpeechKit框架?

import WatchKit 
import Foundation 
import Speech 

class SpeechInterfaceController: WKInterfaceController, SFSpeechRecognizerDelegate { 

override func awake(withContext context: Any?) { 
    super.awake(withContext: context) 

    // Configure interface objects here. 
} 

override func willActivate() { 
    // This method is called when watch view controller is about to be visible to user 
    super.willActivate() 
} 

override func didDeactivate() { 
    // This method is called when watch view controller is no longer visible 
    super.didDeactivate() 
} 

}

+0

Pl。发布您的代码并错误地获得。 –

+0

我添加了代码和错误消息 – Derivative

回答

1

语音框架不在watchOS SDK中(至少在watchOS 3.0-3.1中)。你可以看到这个in the framework docs

speech framework docs screenshot

(如果它支持watchOS,tvOS或MacOS,那些将SDK在该网页上列出)。

您还可以看到一组可用的框架在您的Xcode SDK中:查看Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS3.1.sdk/System/Library/Frameworks/或查看ObOSC版本的watchOS系统头文件时,或在手动添加到链接框架和库中的可用选项列表中,查看Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS3.1.sdk/System/Library/Frameworks/或Xcode编辑器窗格顶部的跳转栏项目的WatchKit扩展目标。

-1

SpeechKit框架不适用于watchOS 3.

要获得在语音识别观看应用程序,你可以改为使用:

presentTextInputController(withSuggestions: nil, allowedInputMode: .plain) { (results) in 
    if let results = results?.first as? String { 
     self.label.setText(results) 
    } 
} 
+0

我不明白为什么-1? – Anthony