diff options
Diffstat (limited to 'src/objective-c')
-rw-r--r-- | src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 122 | ||||
-rw-r--r-- | src/objective-c/!ProtoCompiler.podspec | 136 | ||||
-rw-r--r-- | src/objective-c/BoringSSL.podspec | 7 | ||||
-rw-r--r-- | src/objective-c/GRPCClient/GRPCCall.m | 8 | ||||
-rw-r--r-- | src/objective-c/README.md | 109 | ||||
-rw-r--r-- | src/objective-c/examples/RemoteTestClient/RemoteTest.podspec | 21 | ||||
-rw-r--r-- | src/objective-c/examples/Sample/Podfile | 3 | ||||
-rw-r--r-- | src/objective-c/examples/SwiftSample/Podfile | 3 | ||||
-rw-r--r-- | src/objective-c/tests/Podfile | 14 | ||||
-rw-r--r-- | src/objective-c/tests/RemoteTestClient/RemoteTest.podspec | 26 |
10 files changed, 389 insertions, 60 deletions
diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec new file mode 100644 index 0000000000..72cadb9319 --- /dev/null +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -0,0 +1,122 @@ +# CocoaPods podspec for the gRPC Proto Compiler Plugin + +# Copyright 2016, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Pod::Spec.new do |s| + # This pod is only a utility that will be used by other pods _at install time_ (not at compile + # time). Other pods can access it in their `prepare_command` script, under <pods_root>/<pod name>. + # Because CocoaPods installs pods in alphabetical order, beginning this pod's name with an + # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed + # before them. + s.name = '!ProtoCompiler-gRPCPlugin' + v = '0.14.0' + s.version = v + s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' + s.description = <<-DESC + This podspec only downloads the gRPC protoc plugin so that local pods generating protos can use + it in their invocation of protoc, as part of their prepare_command. + The generated code will have a dependency on the gRPC Objective-C Proto runtime of the same + version. The runtime can be obtained as the "gRPC-ProtoRPC" pod. + DESC + s.homepage = 'http://www.grpc.io' + s.license = { + :type => 'New BSD', + :text => <<-LICENSE + Copyright 2015, Google Inc. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + LICENSE + } + s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } + + repo = 'grpc/grpc' + release = 'release-0_14_1' + file = "grpc_objective_c_plugin-#{v}-macos-x86_64.zip" + s.source = { + :http => "https://github.com/#{repo}/releases/download/#{release}/#{file}", + # TODO(jcanizales): Add sha1 or sha256 + # :sha1 => '??', + } + + repo_root = '../..' + plugin = 'grpc_objective_c_plugin' + + s.preserve_paths = plugin + + # Restrict the protoc version to the one supported by this plugin. + s.dependency '!ProtoCompiler', '3.0.0-beta-3.1' + # For the Protobuf dependency not to complain: + s.ios.deployment_target = '7.1' + s.osx.deployment_target = '10.9' + # Restrict the gRPC runtime version to the one supported by this plugin. + s.dependency 'gRPC-ProtoRPC', v + + # This is only for local development of the plugin: If the Podfile brings this pod from a local + # directory using `:path`, CocoaPods won't download the zip file and so the plugin won't be + # present in this pod's directory. We use that knowledge to check for the existence of the file + # and, if absent, compile the plugin from the local sources. + s.prepare_command = <<-CMD + if [ ! -f #{plugin} ]; then + cd #{repo_root} + # This will build the plugin and put it in #{repo_root}/bins/opt. + # + # TODO(jcanizales): I reckon make will try to use locally-installed libprotoc (headers and + # library binary) if found, which _we do not want_. Find a way for this to always use the + # sources in the repo. + make #{plugin} + cd - + fi + CMD +end diff --git a/src/objective-c/!ProtoCompiler.podspec b/src/objective-c/!ProtoCompiler.podspec new file mode 100644 index 0000000000..5e59b25aee --- /dev/null +++ b/src/objective-c/!ProtoCompiler.podspec @@ -0,0 +1,136 @@ +# Proto Compiler CocoaPods podspec + +# Copyright 2016, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Pod::Spec.new do |s| + # This pod is only a utility that will be used by other pods _at install time_ (not at compile + # time). Other pods can access it in their `prepare_command` script, under <pods_root>/<pod name>. + # Because CocoaPods installs pods in alphabetical order, beginning this pod's name with an + # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed + # before them. + s.name = '!ProtoCompiler' + v = '3.0.0-beta-3.1' + s.version = v + s.summary = 'The Protobuf Compiler (protoc) generates Objective-C files from .proto files' + s.description = <<-DESC + This podspec only downloads protoc so that local pods generating protos can execute it as part + of their prepare_command. + The generated code will have a dependency on the Protobuf Objective-C runtime of the same + version. The runtime can be obtained as the "Protobuf" pod. + DESC + s.homepage = 'https://github.com/google/protobuf' + s.license = { + :type => 'New BSD', + :text => <<-LICENSE + This license applies to all parts of Protocol Buffers except the following: + + - Atomicops support for generic gcc, located in + src/google/protobuf/stubs/atomicops_internals_generic_gcc.h. + This file is copyrighted by Red Hat Inc. + + - Atomicops support for AIX/POWER, located in + src/google/protobuf/stubs/atomicops_internals_power.h. + This file is copyrighted by Bloomberg Finance LP. + + Copyright 2014, Google Inc. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + Code generated by the Protocol Buffer compiler is owned by the owner + of the input file used when generating it. This code is not + standalone and requires a support library to be linked with it. This + support library is itself covered by the above license. + LICENSE + } + # "The name and email addresses of the library maintainers, not the Podspec maintainer." + s.authors = { 'The Protocol Buffers contributors' => 'protobuf@googlegroups.com' } + + repo = 'google/protobuf' + release = "v#{v}" + file = "protoc-#{v}-osx-x86_64.zip" + s.source = { + :http => "https://github.com/#{repo}/releases/download/#{release}/#{file}", + # TODO(jcanizales): Add sha1 or sha256 + # :sha1 => '??', + } + + s.preserve_paths = 'protoc', + 'google/**/*.proto' # Well-known protobuf types + + # Restrict the protobuf runtime version to the one supported by this version of protoc. + s.dependency 'Protobuf', v + # For the Protobuf dependency not to complain: + s.ios.deployment_target = '7.1' + s.osx.deployment_target = '10.9' + + # This is only for local development of protoc: If the Podfile brings this pod from a local + # directory using `:path`, CocoaPods won't download the zip file and so the compiler won't be + # present in this pod's directory. We use that knowledge to check for the existence of the file + # and, if absent, build it from the local sources. + repo_root = '../..' + plugin = 'grpc_objective_c_plugin' + s.prepare_command = <<-CMD + if [ ! -f protoc ]; then + cd #{repo_root} + # This will build protoc from the Protobuf submodule of gRPC, and put it in + # #{repo_root}/bins/opt/protobuf. + # + # TODO(jcanizales): Make won't build protoc from sources if one's locally installed, which + # _we do not want_. Find a way for this to always build from source. + make #{plugin} + cd - + fi + CMD + +end diff --git a/src/objective-c/BoringSSL.podspec b/src/objective-c/BoringSSL.podspec index 26a0451f7d..42b4434d0d 100644 --- a/src/objective-c/BoringSSL.podspec +++ b/src/objective-c/BoringSSL.podspec @@ -109,8 +109,6 @@ Pod::Spec.new do |s| s.subspec 'Interface' do |ss| ss.header_mappings_dir = 'include/openssl' ss.source_files = 'include/openssl/*.h' - # Doesn't compile correctly; but doesn't seem to be needed: - ss.exclude_files = 'include/openssl/arm_arch.h' end s.subspec 'Implementation' do |ss| ss.header_mappings_dir = '.' @@ -147,6 +145,11 @@ Pod::Spec.new do |s| #include "ssl.h" #include "crypto.h" #include "aes.h" + /* The following macros are defined by base.h. The latter is the first file included by the + other headers. */ + #if defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64) + # include "arm_arch.h" + #endif #include "asn1.h" #include "asn1_mac.h" #include "asn1t.h" diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index da9473f9a2..05a1d10f6d 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -208,13 +208,9 @@ NSString * const kGRPCTrailersKey = @"io.grpc.TrailersKey"; // don't want to throw, because the app shouldn't crash for a behavior // that's on the hands of any server to have. Instead we finish and ask // the server to cancel. - // - // TODO(jcanizales): No canonical code is appropriate for this situation - // (because it's just a client problem). Use another domain and an - // appropriately-documented code. [weakSelf finishWithError:[NSError errorWithDomain:kGRPCErrorDomain - code:GRPCErrorCodeInternal - userInfo:nil]]; + code:GRPCErrorCodeResourceExhausted + userInfo:@{NSLocalizedDescriptionKey: @"Client does not have enough memory to hold the server response."}]]; [weakSelf cancelCall]; return; } diff --git a/src/objective-c/README.md b/src/objective-c/README.md index 736c324ca9..a0ca5f448a 100644 --- a/src/objective-c/README.md +++ b/src/objective-c/README.md @@ -1,12 +1,12 @@ [![Cocoapods](https://img.shields.io/cocoapods/v/gRPC.svg)](https://cocoapods.org/pods/gRPC) # gRPC for Objective-C -- [Install protoc with the gRPC plugin](#install) - [Write your API declaration in proto format](#write-protos) - [Integrate a proto library in your project](#cocoapods) - [Use the generated library in your code](#use) - [Use gRPC without Protobuf](#no-proto) -- [Alternative installation methods](#alternatives) +- [Alternatives to the steps above](#alternatives) + - [Install protoc with the gRPC plugin](#install) - [Install protoc and the gRPC plugin without using Homebrew](#no-homebrew) - [Integrate the generated gRPC library without using Cocoapods](#no-cocoapods) @@ -15,18 +15,6 @@ usage and adds some interoperability guarantees. Here we use [Protocol Buffers][ plugin for the Protobuf Compiler (_protoc_) to generate client libraries to communicate with gRPC services. -<a name="install"></a> -## Install protoc with the gRPC plugin - -On Mac OS X, install [homebrew][]. - -Run the following command to install _protoc_ and the gRPC _protoc_ plugin: -```sh -$ curl -fsSL https://goo.gl/getgrpc | bash - -``` -This will download and run the [gRPC install script][]. After the command completes, you're ready to -proceed. - <a name="write-protos"></a> ## Write your API declaration in proto format @@ -40,7 +28,8 @@ Install [Cocoapods](https://cocoapods.org/#install). You need to create a Podspec file for your proto library. You may simply copy the following example to the directory where your `.proto` files are located, updating the name, version and license as -necessary: +necessary. You also need to set the `pods_root` variable to the correct value, depending on where +you place this podspec relative to your Podfile. ```ruby Pod::Spec.new do |s| @@ -55,16 +44,44 @@ Pod::Spec.new do |s| s.ios.deployment_target = '7.1' s.osx.deployment_target = '10.9' + # Base directory where the .proto files are. + src = '.' + + # We'll use protoc with the gRPC plugin. + s.dependency '!ProtoCompiler-gRPCPlugin', '~> 0.14' + + # Pods directory corresponding to this app's Podfile, relative to the location of this podspec. + pods_root = '<path to your Podfile>/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 you want the generated files to be placed. This is an example. + dir = "#{pods_root}/#{s.name}" + # Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients. # You can run this command manually if you later change your protos and need to regenerate. - s.prepare_command = "protoc --objc_out=. --objcgrpc_out=. *.proto" + # Alternatively, you can advance the version of this podspec and run `pod update`. + 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}/*.proto + CMD # The --objc_out plugin generates a pair of .pbobjc.h/.pbobjc.m files for each .proto file. - s.subspec "Messages" do |ms| - ms.source_files = "*.pbobjc.{h,m}" - ms.header_mappings_dir = "." + s.subspec 'Messages' do |ms| + ms.source_files = "#{dir}/*.pbobjc.{h,m}" + ms.header_mappings_dir = dir ms.requires_arc = false - ms.dependency "Protobuf", "~> 3.0.0-beta-2" + # The generated files depend on the protobuf runtime. + ms.dependency 'Protobuf' # This is needed by all pods that depend on Protobuf: ms.pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1', @@ -73,11 +90,12 @@ Pod::Spec.new do |s| # The --objcgrpc_out plugin generates a pair of .pbrpc.h/.pbrpc.m files for each .proto file with # a service defined. - s.subspec "Services" do |ss| - ss.source_files = "*.pbrpc.{h,m}" - ss.header_mappings_dir = "." + s.subspec 'Services' do |ss| + ss.source_files = "#{dir}/*.pbrpc.{h,m}" + ss.header_mappings_dir = dir ss.requires_arc = true - ss.dependency "gRPC-ProtoRPC", "~> 0.14" + # The generated files depend on the gRPC runtime, and on the files generated by `--objc_out`. + ss.dependency 'gRPC-ProtoRPC' ss.dependency "#{s.name}/Messages" end end @@ -89,11 +107,14 @@ Note: If your proto files are in a directory hierarchy, you might want to adjust the sample Podspec above. For example, you could use: ```ruby - s.prepare_command = "protoc --objc_out=. --objcgrpc_out=. *.proto **/*.proto" + s.prepare_command = <<-CMD + ... + #{src}/*.proto #{src}/**/*.proto + CMD ... - ms.source_files = "*.pbobjc.{h,m}", "**/*.pbobjc.{h,m}" + ms.source_files = "#{dir}/*.pbobjc.{h,m}", "#{dir}/**/*.pbobjc.{h,m}" ... - ss.source_files = "*.pbrpc.{h,m}", "**/*.pbrpc.{h,m}" + ss.source_files = "#{dir}/*.pbrpc.{h,m}", "#{dir}/**/*.pbrpc.{h,m}" ``` Once your library has a Podspec, Cocoapods can install it into any XCode project. For that, go into @@ -121,19 +142,33 @@ pod install <a name="use"></a> ## Use the generated library in your code -Please check this [sample app][] for examples of how to use a generated gRPC library. +Please check the [example apps][] for examples of how to use a generated gRPC library. <a name="no-proto"></a> ## Use gRPC without Protobuf -The [sample app][] has an example of how to use the generic gRPC Objective-C client without -generated files. +This [tests file](https://github.com/grpc/grpc/tree/master/src/objective-c/tests/GRPCClientTests.m) +shows how to use the generic gRPC Objective-C client without generated protobuf files. <a name="alternatives"></a> -## Alternative installation methods +## Alternatives to the steps above + +<a name="install"></a> +### Install _protoc_ with the gRPC plugin + +Although it's not recommended (because it can lead to hard-to-solve version conflicts), it is +sometimes more convenient to install _protoc_ and the gRPC plugin in your development machine, +instead of letting Cocoapods download the appropriate versions for you. To do so, on Mac OS X or +later, install [homebrew][]. + +The run the following command to install _protoc_ and the gRPC _protoc_ plugin: +```sh +$ curl -fsSL https://goo.gl/getgrpc | bash - +``` +This will download and run the [gRPC install script][]. <a name="no-homebrew"></a> -### Install protoc and the gRPC plugin without using Homebrew +### Install _protoc_ and the gRPC plugin without using Homebrew First install v3 of the Protocol Buffers compiler (_protoc_), by cloning [its Git repository](https://github.com/google/protobuf) and following these @@ -145,15 +180,15 @@ cloned. Compile the gRPC plugins for _protoc_: ```sh -make plugins +make grpc_objective_c_plugin ``` Create a symbolic link to the compiled plugin binary somewhere in your `$PATH`: ```sh ln -s `pwd`/bins/opt/grpc_objective_c_plugin /usr/local/bin/protoc-gen-objcgrpc ``` -(Notice that the name of the created link must begin with "protoc-gen-" for _protoc_ to recognize it -as a plugin). +(Notice that the name of the created link must begin with "`protoc-gen-`" for _protoc_ to recognize +it as a plugin). If you don't want to create the symbolic link, you can alternatively copy the binary (with the appropriate name). Or you might prefer instead to specify the plugin's path as a flag when invoking @@ -178,5 +213,5 @@ Objective-C Protobuf runtime library. [Protocol Buffers]:https://developers.google.com/protocol-buffers/ [homebrew]:http://brew.sh [gRPC install script]:https://raw.githubusercontent.com/grpc/homebrew-grpc/master/scripts/install -[example Podfile]:https://github.com/grpc/grpc/blob/master/src/objective-c/examples/Sample/Podfile -[sample app]: https://github.com/grpc/grpc/tree/master/src/objective-c/examples/Sample +[example Podfile]:https://github.com/grpc/grpc/blob/master/examples/objective-c/helloworld/Podfile +[example apps]: https://github.com/grpc/grpc/tree/master/examples/objective-c diff --git a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec index e3b50ddea5..6e783fb5ad 100644 --- a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec +++ b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec @@ -11,15 +11,30 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.9' # Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients. + s.dependency "!ProtoCompiler-gRPCPlugin", "~> 0.14" + + repo_root = '../../../..' + bin_dir = "#{repo_root}/bins/$CONFIG" + + protoc = "#{bin_dir}/protobuf/protoc" + well_known_types_dir = "#{repo_root}/third_party/protobuf/src" + plugin = "#{bin_dir}/grpc_objective_c_plugin" + s.prepare_command = <<-CMD - protoc --objc_out=. --objcgrpc_out=. *.proto + #{protoc} \ + --plugin=protoc-gen-grpc=#{plugin} \ + --objc_out=. \ + --grpc_out=. \ + -I . \ + -I #{well_known_types_dir} \ + *.proto CMD s.subspec 'Messages' do |ms| ms.source_files = '*.pbobjc.{h,m}' ms.header_mappings_dir = '.' ms.requires_arc = false - ms.dependency 'Protobuf', '~> 3.0.0-beta-3.1' + ms.dependency 'Protobuf' # This is needed by all pods that depend on Protobuf: ms.pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1', @@ -30,7 +45,7 @@ Pod::Spec.new do |s| ss.source_files = '*.pbrpc.{h,m}' ss.header_mappings_dir = '.' ss.requires_arc = true - ss.dependency 'gRPC-ProtoRPC', '~> 0.14' + ss.dependency 'gRPC-ProtoRPC' ss.dependency "#{s.name}/Messages" end end diff --git a/src/objective-c/examples/Sample/Podfile b/src/objective-c/examples/Sample/Podfile index 80ab2c320d..8740b2f963 100644 --- a/src/objective-c/examples/Sample/Podfile +++ b/src/objective-c/examples/Sample/Podfile @@ -12,6 +12,9 @@ target 'Sample' do # Use the local versions of Protobuf, BoringSSL, and gRPC. You don't need any of the following # lines in your application. + pod '!ProtoCompiler', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" + pod '!ProtoCompiler-gRPCPlugin', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" + pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf" pod 'BoringSSL', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c" diff --git a/src/objective-c/examples/SwiftSample/Podfile b/src/objective-c/examples/SwiftSample/Podfile index b675fd29ef..2f783340f5 100644 --- a/src/objective-c/examples/SwiftSample/Podfile +++ b/src/objective-c/examples/SwiftSample/Podfile @@ -12,6 +12,9 @@ target 'SwiftSample' do # Use the local versions of Protobuf, BoringSSL, and gRPC. You don't need any of the following # lines in your application. + pod '!ProtoCompiler', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" + pod '!ProtoCompiler-gRPCPlugin', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" + pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf" pod 'BoringSSL', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c" diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile index 30a34260d4..17b9740d52 100644 --- a/src/objective-c/tests/Podfile +++ b/src/objective-c/tests/Podfile @@ -17,12 +17,18 @@ GRPC_LOCAL_SRC = '../../..' ).each do |target_name| target target_name do pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf", :inhibit_warnings => true - pod 'BoringSSL', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true + + pod '!ProtoCompiler', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" + pod '!ProtoCompiler-gRPCPlugin', :path => "#{GRPC_LOCAL_SRC}/src/objective-c" + + pod 'BoringSSL', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true pod 'CronetFramework', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c" - pod 'gRPC', :path => GRPC_LOCAL_SRC - pod 'gRPC-Core', :path => GRPC_LOCAL_SRC + + pod 'gRPC', :path => GRPC_LOCAL_SRC + pod 'gRPC-Core', :path => GRPC_LOCAL_SRC pod 'gRPC-RxLibrary', :path => GRPC_LOCAL_SRC pod 'gRPC-ProtoRPC', :path => GRPC_LOCAL_SRC + pod 'RemoteTest', :path => "RemoteTestClient" end end @@ -65,7 +71,7 @@ post_install do |installer| end if target.name == 'gRPC-Core' target.build_configurations.each do |config| - # TODO(zyc) Remove this setting after the issue is resolved + # TODO(zyc): Remove this setting after the issue is resolved # GPR_UNREACHABLE_CODE causes "Control may reach end of non-void # function" warning config.build_settings['GCC_WARN_ABOUT_RETURN_TYPE'] = 'NO' diff --git a/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec b/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec index 25c9c7f841..7d84a5ae4d 100644 --- a/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec +++ b/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec @@ -11,20 +11,30 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.9' # Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients. + s.dependency "!ProtoCompiler-gRPCPlugin", "~> 0.14" + + repo_root = '../../../..' + bin_dir = "#{repo_root}/bins/$CONFIG" + + protoc = "#{bin_dir}/protobuf/protoc" + well_known_types_dir = "#{repo_root}/third_party/protobuf/src" + plugin = "#{bin_dir}/grpc_objective_c_plugin" + s.prepare_command = <<-CMD - BINDIR=../../../../bins/$CONFIG - PROTOC=$BINDIR/protobuf/protoc - PLUGIN=$BINDIR/grpc_objective_c_plugin - # we use this path to locate well-known proto files - PROTO_SRC=../../../../third_party/protobuf/src - $PROTOC --plugin=protoc-gen-grpc=$PLUGIN --objc_out=. --grpc_out=. *.proto -I $PROTO_SRC -I . + #{protoc} \ + --plugin=protoc-gen-grpc=#{plugin} \ + --objc_out=. \ + --grpc_out=. \ + -I . \ + -I #{well_known_types_dir} \ + *.proto CMD s.subspec "Messages" do |ms| ms.source_files = "*.pbobjc.{h,m}" ms.header_mappings_dir = "." ms.requires_arc = false - ms.dependency "Protobuf", "~> 3.0.0-beta-3.1" + ms.dependency "Protobuf" # This is needed by all pods that depend on Protobuf: ms.pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1', @@ -35,7 +45,7 @@ Pod::Spec.new do |s| ss.source_files = "*.pbrpc.{h,m}" ss.header_mappings_dir = "." ss.requires_arc = true - ss.dependency "gRPC-ProtoRPC", "~> 0.14" + ss.dependency "gRPC-ProtoRPC" ss.dependency "#{s.name}/Messages" end end |