OLD | NEW |
(Empty) | |
| 1 #gRPC in 3 minutes (Objective-C) |
| 2 |
| 3 ## Installation |
| 4 |
| 5 To run this example you should have [Cocoapods](https://cocoapods.org/#install)
installed, as well |
| 6 as the relevant tools to generate the client library code (and a server in anoth
er language, for |
| 7 testing). You can obtain the latter by following [these setup instructions](http
s://github.com/grpc/homebrew-grpc). |
| 8 |
| 9 ## Hello Objective-C gRPC! |
| 10 |
| 11 Here's how to build and run the Objective-C implementation of the [Hello World](
../../protos/helloworld.proto) |
| 12 example used in [Getting started](https://github.com/grpc/grpc/tree/master/examp
les). |
| 13 |
| 14 The example code for this and our other examples lives in the `examples` directo
ry. Clone |
| 15 this repository to your local machine by running the following commands: |
| 16 |
| 17 |
| 18 ```sh |
| 19 $ git clone https://github.com/grpc/grpc.git |
| 20 $ cd grpc |
| 21 $ git submodule update --init |
| 22 ``` |
| 23 |
| 24 Change your current directory to `examples/objective-c/helloworld` |
| 25 |
| 26 ```sh |
| 27 $ cd examples/objective-c/helloworld |
| 28 ``` |
| 29 |
| 30 ### Try it! |
| 31 To try the sample app, we need a gRPC server running locally. Let's compile and
run, for example, |
| 32 the C++ server in this repository: |
| 33 |
| 34 ```shell |
| 35 $ pushd ../../cpp/helloworld |
| 36 $ make |
| 37 $ ./greeter_server & |
| 38 $ popd |
| 39 ``` |
| 40 |
| 41 Now have Cocoapods generate and install the client library for our .proto files: |
| 42 |
| 43 ```shell |
| 44 $ pod install |
| 45 ``` |
| 46 |
| 47 (This might have to compile OpenSSL, which takes around 15 minutes if Cocoapods
doesn't have it yet |
| 48 on your computer's cache.) |
| 49 |
| 50 Finally, open the XCode workspace created by Cocoapods, and run the app. You can
check the calling |
| 51 code in `main.m` and see the results in XCode's log console. |
| 52 |
| 53 The code sends a `HLWHelloRequest` containing the string "Objective-C" to a loca
l server. The server |
| 54 responds with a `HLWHelloResponse`, which contains a string that is then output
to the log. |
| 55 |
| 56 ## Tutorial |
| 57 |
| 58 You can find a more detailed tutorial in [gRPC Basics: Objective-C](http://www.g
rpc.io/docs/tutorials/basic/objective-c.html). |
OLD | NEW |