0
votes

I'm trying to build the compile environment of .proto files for grpc on my macbook. My current local protobuf version is 3.11.4 in my iOS project, but the latest grpc direct to protobuf 3.15.8. I have customized my protobuf code for some reason, so I don't want to upgrade it, and so does the compile environment.

my question is: can I keep my local old version protobuf(3.11.4) environment while install grpc environment at the same time?

When I use pod install to generate xx.pbobjc.h xx.pbobjc.m xx.pbrpc.h xx.pbrpc.m, it shows an error in the file

#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.

and when I use cmd in terminal like this

protoc -I .  --objc_out=./output --grpc_out=./output --plugin=protoc-gen-grpc=grpc_objective_c_plugin search.proto

it goes

dyld: Library not loaded: /usr/local/opt/protobuf/lib/libprotoc.26.dylib
  Referenced from: /Users/rose/Documents/Code/JobProjects/grpcProto/grpc_objective_c_plugin
  Reason: image not found

looks like it has linked to a higher version protobuf.

here's my protobuf version

$ protoc --version
libprotoc 3.11.4

'brew install grpc' dependent the latest protobuf(3.15.8), I guess I should clone grpc down and build the environment by myself and so I did, but it seems grpc doesn't link with my old protobuf still when I try to generate code from .proto file, can anybody tell me how to make it happen? Have I make this clear? please tell me if i don't

1
This is going to be language/framework specific; what works in Java might not work in C, might work in C#, might not work in Python. Can you be more specific? The actual RPC and marahaller cores aren't inherently linked, but whether that purity exists in the implementation is implementation specific - Marc Gravell♦
@MarcGravell sorry I didn't make it clear, it's not about project, it's about the compile environment which I need it to generate objective-c code from .proto files. I'm using objective-c in my iOS project, if you asked. thank you - Chloe Wang

1 Answers

0
votes

I finally get the answer. it's the Homebrew's fault, the grpc_objective_c_plugin generated by 'brew install grpc' only relies on 3.15.8 protobuf, lower versions won't work. my colleague has the 3.11.4 protobuf environment, and he runs the newest compile plugin successfully which is downloaded from github...After modify some #import code, compiled files build in my project with no errors.

For an iOS developer, no need to 'make install' grpc project, what u need to do is just create .podspec file as grpc document and modify the podfile, after 'pod install' there will be a grpc_objective_c_plugin file under the Pods/!ProtoCompiler-gRPCPlugin/, this plugin relies on the protobuf environment on your computer, the limitation of Protobuf version should be >=3

hope this will help whoever comes to this.