Search code examples
swiftgoogle-apiswift4header-filesgoogle-speech-api

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


Has anyone been able to successfully build Google's Speech to Text iOS example in Swift 4?

The swift project posted to the Github repo: GoogleCloudPlatform/ios-docs-samples does not seem to be well-maintained. When I open the workspace example, I immediately get 3 build errors in locating header files and "could not build module googleapis."

On installing googleapis

I looked up documentation on pod install for pod 'googleapis', :path=> "." but this produces the following error: [!] No podspec found for googleapis in . I found the googleapis.podspec and downloaded the .zip file and when I did a pod install, got this error:

[!] /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

On $ npm install googleapis, I get errors:

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.

On locating Header files

Even after pointing it to the correct path in Build Settings > Header Search Paths, the headers are still unable to be found.

missing header file even though it exists

added Header Search Paths

If someone can help correct those above 2 issues OR provide a working iOS example of the Google Speech to Text integrated .xcodeproj example, would be much appreciated!

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


Solution

  • I had problems getting this sample to work as well until I realised that that you are supposed to run the script ./INSTALL-COCOAPODS instead of just doing a regular pod install. This fixes up some paths after installing the pods. Alternatively, you can follow the instructions in the BUILDFIXES file in the repo.

    It's annoying that it doesn't just work like any other project, but at least, once you read the manual, it is an easy enough fix.