【问题标题】:Sharpie import not found找不到Sharpie导入
【发布时间】:2018-03-28 14:35:45
【问题描述】:

上下文

我必须使用 Google Cloud Speech api 在 Xamarin.iOS 应用中实现 Speech to Text 功能。

音频需要在用户说话时进行流式传输,以便我们能够尽快显示用户所说的内容。

首先,我尝试使用 Google.Cloud.Speech.V1 Nuget 包,但 gRPC 库似乎不适用于 Xamarin(https://github.com/grpc/grpc/issues/1620https://forums.xamarin.com/discussion/94534/how-to-use-google-cloud-speech-api-within-xamarin-formsXamarin, Grpc, Could not resolve type with token 0100002b)。

所以我尝试在这个样本上创建一个绑定:https://github.com/GoogleCloudPlatform/ios-docs-samples/tree/master/speech/Objective-C/Speech-gRPC-Streaming

我创建了一个静态库,只保留了 SpeechRecognitionService.hSpeechRecognitionService.m 文件并生成了 *.a fat 库。

问题

我必须使用 Sharpie 生成 ApiDefinition.cs。 于是我执行了命令sharpie bind -sdk iphoneos11.2 -output Output -scope . [full-path-to-SpeechRecognitionService.h]。我尝试了一些clang选项,但每次我都遇到这种错误:

Parsing 1 header files...
[full-path-to-project]/SpeechRecognitionService.h:18:9: fatal error: 
      'google/cloud/speech/v1/CloudSpeech.pbrpc.h' file not found
#import "google/cloud/speech/v1/CloudSpeech.pbrpc.h"
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Binding...
1 error generated.
Error while processing [full-path-to-project]/SpeechRecognitionService.h.

Done. Exiting with error code 1.
error: Clang failed to parse input and exited with code 1

似乎我必须传递一些 clang 参数来判断标题在哪里,但它们并不都在一个文件夹中。

如何让 Sharpie 在多个文件夹中搜索标题?

【问题讨论】:

    标签: xamarin.ios google-cloud-speech objective-sharpie


    【解决方案1】:

    您可以使用*.h匹配项目文件夹下的所有头文件。

    例如

    sharpie bind --output=InfColorPicker --namespace=InfColorPicker --sdk=[iphone-os] [full-path-to-project]/InfColorPicker/InfColorPicker/*.h
    

    你可以在official documentation搜索这个

    【讨论】:

    • 谢谢,但我已经尝试过了(即使使用 [full-path-to-project]/**/*.h),但我仍然遇到同样的问题。找不到导入。
    • 对不起,我误会了。我建议你使用 CocoaPods docs.microsoft.com/en-us/xamarin/cross-platform/macios/binding/… 创建这个
    • 没问题 ;-)。我没有提到它,但我也尝试过这个,但是由于 googleapis 是这个 iOS 项目的本地 pod,而不是在 cocopoads 存储库中,因此该命令找不到它。编辑:我也尝试绑定 Xcode 项目,但是找不到 lPods 库存在问题:/.
    • 知道了,但我之前没听说过(用不同文件夹中的头文件创建ApiDefinition)。检查Sharpie命令here,我认为我们需要将所有头文件保存在同一个文件夹中..
    • 好的,这意味着我必须重构所有谷歌生成的代码并希望最好:/
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-19
    • 2015-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多