Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c GRPC prbc.h类未生成目标-c_Objective C_React Native_Cocoapods_Protocol Buffers_Grpc - Fatal编程技术网

Objective c GRPC prbc.h类未生成目标-c

Objective c GRPC prbc.h类未生成目标-c,objective-c,react-native,cocoapods,protocol-buffers,grpc,Objective C,React Native,Cocoapods,Protocol Buffers,Grpc,我正在尝试将GRPC与react native一起使用。而基本的helloWorld示例可以很好地使用它。当我将新请求添加到Helloworld.proto文件时,它没有生成/更新Helloworld.prbc.h文件 helloworld.proto syntax = "proto3"; option objc_class_prefix = "HLW"; package helloworld; // The greeting ser

我正在尝试将GRPC与react native一起使用。而基本的helloWorld示例可以很好地使用它。当我将新请求添加到Helloworld.proto文件时,它没有生成/更新Helloworld.prbc.h文件

helloworld.proto

  syntax = "proto3";

  option objc_class_prefix = "HLW";

  package helloworld;

  // The greeting service definition.
  service Greeter {
      // Sends a greeting
      rpc SayHello (HelloRequest) returns (HelloReply) {}
      rpc HelloDev (HelloDevRequest) returns (HelloDevReply) {}
  }

  // The request message containing the user's name.
  message HelloRequest {
      string name = 1;
  }

  // The response message containing the greetings
  message HelloReply {
      string message = 1;
  }

  // The request message containing the user's name.
  message HelloDevRequest {
      string name = 1;
  }

  // The response message containing the greetings
  message HelloDevReply {
      string message = 1;
  }
我试过:

pod install
安装pod后,我希望Helloworld.prbc.h对HelloDev有定义。 另一种方式:

protoc --objc_out=Pods/ReactNativeGrpc --objcgrpc_out=Pods/ReactNativeGrpc helloworld.proto
ReactNativeGrpc是我的项目的pod

这是编译器自动生成的文件(即使在运行pod安装后也是如此)

ReactNativeGRPC.Podspec:

    Pod::Spec.new do |s|
    s.name     = "ReactNativeGrpc"
    s.version  = "0.0.1"
    s.license  = "Apache License, Version 2.0"
    s.authors  = { 'gRPC contributors' => 'grpc-io@googlegroups.com' }
    s.homepage = "https://grpc.io/"
    s.summary = "Example integration between react-native and GRPC"
    s.source = { :git => 'https://github.com/grpc/grpc.git' }

    s.ios.deployment_target = "7.1"
    s.osx.deployment_target = "10.9"

    # Base directory where the .proto files are.
    src = "../proto"

    # Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients.
    s.dependency "!ProtoCompiler-gRPCPlugin", "~> 1.0"

    # Pods directory corresponding to this app's Podfile, relative to the location of this podspec.
    pods_root = 'Pods'

    # Path where Cocoapods downloads protoc and the gRPC plugin.
    protoc_dir = "#{pods_root}/!ProtoCompiler"
    protoc = "#{protoc_dir}/protoc"
    plugin = "#{pods_root}/!ProtoCompiler-gRPCPlugin/grpc_objective_c_plugin"

    # Directory where the generated files will be placed.
    dir = "#{pods_root}/#{s.name}"

    s.prepare_command = <<-CMD
      mkdir -p #{dir}
      #{protoc} \
          --plugin=protoc-gen-grpc=#{plugin} \
          --objc_out=#{dir} \
          --grpc_out=#{dir} \
          -I #{src} \
          -I #{protoc_dir} \
          #{src}/helloworld.proto
    CMD

    # Files generated by protoc
    s.subspec "Messages" do |ms|
      ms.source_files = "#{dir}/*.pbobjc.{h,m}", "#{dir}/**/*.pbobjc.{h,m}"
      ms.header_mappings_dir = dir
      ms.requires_arc = false
      # The generated files depend on the protobuf runtime.
      ms.dependency "Protobuf"
    end

    # Files generated by the gRPC plugin
    s.subspec "Services" do |ss|
      ss.source_files = "#{dir}/*.pbrpc.{h,m}", "#{dir}/**/*.pbrpc.{h,m}"
      ss.header_mappings_dir = dir
      ss.requires_arc = true
      # The generated files depend on the gRPC runtime, and on the files generated by protoc.
      ss.dependency "gRPC-ProtoRPC"
      ss.dependency "#{s.name}/Messages"
    end

    s.pod_target_xcconfig = {
      # This is needed by all pods that depend on Protobuf:
      'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1',
      # This is needed by all pods that depend on gRPC-RxLibrary:
      'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES',
    }
  end
Pod::Spec.new do|s|
s、 name=“ReactNativeGrpc”
s、 version=“0.0.1”
s、 license=“Apache许可证,版本2.0”
s、 作者={'gRPC贡献者=>'gRPC-io@googlegroups.com' }
s、 主页=”https://grpc.io/"
s、 summary=“react native和GRPC之间的集成示例”
s、 source={:git=>'https://github.com/grpc/grpc.git' }
s、 ios.deployment_target=“7.1”
s、 osx.deployment_target=“10.9”
#.proto文件所在的基本目录。
src=“../proto”
#使用Objective-C和gRPC插件运行protoc,以生成协议消息和gRPC客户端。
s、 依赖项“!ProtoCompiler gRPCPlugin”,“~>1.0”
#与此应用程序的pod文件相对应的Pods目录,相对于此podspec的位置。
pods_根=‘pods’
#Cocoapods下载protoc和gRPC插件的路径。
protoc_dir=“#{pods_root}/!ProtoCompiler”
protoc=“#{protoc_dir}/protoc”
plugin=“#{pods_root}/!原型编译器gRPCPlugin/grpc_objective_c_plugin”
#将放置生成的文件的目录。
dir=“#{pods_root}/#{s.name}”
s、 prepare_命令='YES',
}
结束
想要在代码中使用更新的proto定义,这在这里不起作用


编辑1:每次清理和安装都有效,但需要其他方法来避免。您是否尝试清理Cocoapods缓存?如果没有,请在运行
pod install
之前尝试运行以下命令以清除缓存:

rm -rf Pods
rm -rf (your_project).xcworkspace
rm Podfile.lock

它工作,但我必须这样做,每次原型文件更新。我正试图避免这种情况。
    Pod::Spec.new do |s|
    s.name     = "ReactNativeGrpc"
    s.version  = "0.0.1"
    s.license  = "Apache License, Version 2.0"
    s.authors  = { 'gRPC contributors' => 'grpc-io@googlegroups.com' }
    s.homepage = "https://grpc.io/"
    s.summary = "Example integration between react-native and GRPC"
    s.source = { :git => 'https://github.com/grpc/grpc.git' }

    s.ios.deployment_target = "7.1"
    s.osx.deployment_target = "10.9"

    # Base directory where the .proto files are.
    src = "../proto"

    # Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients.
    s.dependency "!ProtoCompiler-gRPCPlugin", "~> 1.0"

    # Pods directory corresponding to this app's Podfile, relative to the location of this podspec.
    pods_root = 'Pods'

    # Path where Cocoapods downloads protoc and the gRPC plugin.
    protoc_dir = "#{pods_root}/!ProtoCompiler"
    protoc = "#{protoc_dir}/protoc"
    plugin = "#{pods_root}/!ProtoCompiler-gRPCPlugin/grpc_objective_c_plugin"

    # Directory where the generated files will be placed.
    dir = "#{pods_root}/#{s.name}"

    s.prepare_command = <<-CMD
      mkdir -p #{dir}
      #{protoc} \
          --plugin=protoc-gen-grpc=#{plugin} \
          --objc_out=#{dir} \
          --grpc_out=#{dir} \
          -I #{src} \
          -I #{protoc_dir} \
          #{src}/helloworld.proto
    CMD

    # Files generated by protoc
    s.subspec "Messages" do |ms|
      ms.source_files = "#{dir}/*.pbobjc.{h,m}", "#{dir}/**/*.pbobjc.{h,m}"
      ms.header_mappings_dir = dir
      ms.requires_arc = false
      # The generated files depend on the protobuf runtime.
      ms.dependency "Protobuf"
    end

    # Files generated by the gRPC plugin
    s.subspec "Services" do |ss|
      ss.source_files = "#{dir}/*.pbrpc.{h,m}", "#{dir}/**/*.pbrpc.{h,m}"
      ss.header_mappings_dir = dir
      ss.requires_arc = true
      # The generated files depend on the gRPC runtime, and on the files generated by protoc.
      ss.dependency "gRPC-ProtoRPC"
      ss.dependency "#{s.name}/Messages"
    end

    s.pod_target_xcconfig = {
      # This is needed by all pods that depend on Protobuf:
      'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1',
      # This is needed by all pods that depend on gRPC-RxLibrary:
      'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES',
    }
  end
rm -rf Pods
rm -rf (your_project).xcworkspace
rm Podfile.lock