Google Speech to Text iOS 应用示例:无法构建模块 'googleapis'

Google Speech to Text iOS app example: could not build module 'googleapis'

有没有人能够在 Swift 4 中成功构建 Google 的 Speech to Text iOS 示例?

发布到 Github 存储库的 swift 项目:GoogleCloudPlatform/ios-docs-samples 似乎不是 well-maintained。当我打开工作区示例时,我立即在定位 header 文件和 "could not build module googleapis."

时收到 3 个构建错误

关于安装 googleapis

我查找了 pod 'googleapis' 的 pod 安装文档,:path=> "."但这会产生以下错误: [!] No podspec found for googleapis in . 我找到了 googleapis.podspec 并下载了 .zip 文件,当我安装 pod 时,出现了这个错误:

[!] /bin/bash -c set -e Pods/!ProtoCompiler/protoc --plugin=protoc-gen-grpc=Pods/!ProtoCompiler-gRPCPlugin/grpc_objective_c_plugin --objc_out=. --grpc_out=. -I . -I Pods/!ProtoCompiler google//.proto google////.proto google//.proto: No such file or directory

在 $ npm install googleapis 上,我收到错误:

npm WARN saveError ENOENT: no such file or directory, open '/Users/grehce/package.json' npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN enoent ENOENT: no such file or directory, open '/Users/grehce/package.json' npm WARN grehce No description npm WARN grehce No repository field. npm WARN grehce No README data npm WARN grehce No license field.

在定位 Header 个文件时

即使在 Build Settings > Header Search Paths 中将其指向正确的路径,仍然无法找到 headers。

missing header file even though it exists

added Header Search Paths

如果有人可以帮助纠正上述 2 个问题或提供 Google Speech to Text 集成 .xcodeproj 示例的工作 iOS 示例,将不胜感激!

Github: https://github.com/GoogleCloudPlatform/ios-docs-samples/issues/89

非常 烦人并且包含 Google 部分更好的文档。

关于安装 googleapis

  1. 您必须将 iOS 示例项目中的 "google" 文件夹添加到与您的 xcodeproj 相同的文件夹中(这里有点暗示:https://github.com/GoogleCloudPlatform/ios-docs-samples/issues/19)

  2. 您必须忽略 "Cannot load underlying module for googleapis" 并在 googleapis pod 安装成功后强制构建。显然,"Cannot load underlying module for x" 是一个 xcode 错误 (Cocoapods + Cannot load underlying module for 'x')

注:

pod 'googleapis', :path=> "."

在我意识到您应该 运行 脚本 ./INSTALL-COCOAPODS 而不是仅仅执行常规 pod install 之前,我也遇到了使该示例工作的问题。这会在安装 pods 后修复一些路径。或者,您可以按照存储库 BUILDFIXES 文件中的说明进行操作。

令人恼火的是,它不像其他任何项目一样工作,但至少,一旦您阅读了手册,它就很容易修复。