2016-09-23 119 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