将 Microsoft Cognitive SpeechSDK 框架集成到 Swift 应用程序中

Integrating Microsoft Cognitive SpeechSDK framework into a Swift app

我正在尝试将 Microsoft Bing Speech APISpeechRecognitionService 集成到我的 Swift 应用程序中。不幸的是,Microsoft SDK 仅支持 Objective-C atm,因此我在导入 SpeechSDK.framework 后通过将 #import "SpeechRecognitionService.h" 添加到桥接 Header 来绕过,但我得到了 file not found 错误。

我做错了什么?

编辑:

我之前确实尝试过 import SpeechSDK 框架直接进入所需的 class 但它不起作用。

就我而言,我仍在使用桥接 Header 来导入框架。 #import "SpeechRecognitionService.h" 没有用,但下面的小改动对我有用。

#import "SpeechSDK/SpeechRecognitionService.h"

桥接header不需要添加header,直接导入框架即可。来自 apple docs:

Importing External Frameworks

You can import external frameworks that have a pure Objective-C codebase, a pure Swift codebase, or a mixed-language codebase. The process for importing an external framework is the same whether the framework is written in a single language or contains files from both languages. When you import an external framework, make sure the Defines Module build setting for the framework you’re importing is set to “Yes”.

You can import a framework into any Swift file within a different target using the following syntax:

import FrameworkName

另见 “file not found” in Bridging Header when importing Objective-C frameworks into Swift project by CocoaPod

就我而言,我仍在使用 Bridging Header 来导入框架。 #import "SpeechRecognitionService.h" 没有用,但下面的小改动对我有用。

#import "SpeechSDK/SpeechRecognitionService.h"