GoogleCloudPlatform / ios-docs-samples

iOS samples that demonstrate APIs and services of Google Cloud Platform.
Apache License 2.0
329 stars 209 forks source link

StreamingRPC Swift Sample Code doesnt build - stickynote works fine. seems to be an issue with not finding the right headers... #40

Open Daij-Djan opened 7 years ago

Daij-Djan commented 7 years ago

Hi the StreamingRPC Swift Sample Code doesnt build - stickynote works fine.

It seems to be an issue with not finding the finding the right headers...

/Users/dominikpich/Downloads/avr google ios-docs-samples-master/speech/Swift/Speech-gRPC-Streaming/Speech/Speech-Bridging-Header.h:5:9: note: while building module 'googleapis' imported from /Users/dominikpich/Downloads/avr google ios-docs-samples-master/speech/Swift/Speech-gRPC-Streaming/Speech/Speech-Bridging-Header.h:5:
#import <googleapis/CloudSpeech.pbobjc.h>
        ^
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/googleapis-umbrella.h"
        ^
/Users/dominikpich/Library/Developer/Xcode/DerivedData/Speech-hhdczwvtbinadbeughkiimdsnftm/Build/Products/Debug-iphonesimulator/googleapis/googleapis.framework/Headers/googleapis-umbrella.h:15:9: note: in file included from /Users/dominikpich/Library/Developer/Xcode/DerivedData/Speech-hhdczwvtbinadbeughkiimdsnftm/Build/Products/Debug-iphonesimulator/googleapis/googleapis.framework/Headers/googleapis-umbrella.h:15:
#import "CloudSpeech.pbrpc.h"
        ^
/Users/dominikpich/Library/Developer/Xcode/DerivedData/Speech-hhdczwvtbinadbeughkiimdsnftm/Build/Products/Debug-iphonesimulator/googleapis/googleapis.framework/Headers/CloudSpeech.pbrpc.h:1:9: error: 'google/cloud/speech/v1beta1/CloudSpeech.pbobjc.h' file not found
#import "google/cloud/speech/v1beta1/CloudSpeech.pbobjc.h"
        ^
/Users/dominikpich/Downloads/avr google ios-docs-samples-master/speech/Swift/Speech-gRPC-Streaming/Speech/Speech-Bridging-Header.h:5:9: error: could not build module 'googleapis'
#import <googleapis/CloudSpeech.pbobjc.h>
        ^
<unknown>:0: error: failed to import bridging header '/Users/dominikpich/Downloads/avr google ios-docs-samples-master/speech/Swift/Speech-gRPC-Streaming/Speech/Speech-Bridging-Header.h'

https://www.dropbox.com/s/l4ck0envcb4guym/Screenshot%202017-04-05%2010.57.32.png?dl=0

Daij-Djan commented 7 years ago

I got it to build by using an ugly workaround.. I dont 'import googleapis' but instead I copy all the individual includes of its umbrella header to my bridging header and make them truly project relative :) that works but is ugly as hell!

alexiscreuzot commented 7 years ago

I got it working with a post_install script directly in the Podfile :


post_install do |installer|
find_and_replace("google")

#Show BUILDFIXES
puts "\n--------BUILDFIXES--------\n"
puts "Fixing Protocol Buffer toolchain issues"
find_and_replace("google")
puts "----------------------------\n\n"

end

def find_and_replace(dir)
  Dir[dir + '*.*'].each do |name|
        text = File.read(name)

        replace = text.gsub("\"google/cloud/speech/v1beta1/CloudSpeech.pbobjc.h\"", "<googleapis/CloudSpeech.pbobjc.h>")
        replace = replace.gsub("\"google/api/Annotations.pbobjc.h\"", "<googleapis/Annotations.pbobjc.h>")
        replace = replace.gsub("\"google/longrunning/Operations.pbobjc.h\"", "<googleapis/Operations.pbobjc.h>")
        replace = replace.gsub("\"google/rpc/Status.pbobjc.h\"", "<googleapis/Status.pbobjc.h>")

        if text != replace 
            puts "Fixing " + name
            File.open(name, "w") { |file| file.puts replace }
            STDOUT.flush
        end
  end
  Dir[dir + '*/'].each(&method(:find_and_replace))
end```
vin-the-dev commented 6 years ago

Just did a pod update and then gave your code @kirualex then only it worked. Thanks :)

ProAjit commented 5 years ago

After following guidelines listed in build fix file, all these build error gets fixed but can we know by when Google will come up with working sample without need of this build fix -

https://github.com/GoogleCloudPlatform/ios-docs-samples/blob/master/speech/Swift/Speech-gRPC-Streaming/BUILDFIXES