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