blob: 8f6d0d3a8d03c13ac4b69c10962ac5b7bfa21ac2 [file] [log] [blame] [view]
murgatroid995de22f52015-06-12 11:21:55 -07001#gRPC in 3 minutes (Objective-C)
murgatroid99042b9122015-06-11 14:23:32 -07002
3## Installation
4
5To 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
murgatroid995de22f52015-06-12 11:21:55 -07007## Hello Objective-C gRPC!
murgatroid99042b9122015-06-11 14:23:32 -07008
murgatroid995de22f52015-06-12 11:21:55 -07009Here'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).
murgatroid99042b9122015-06-11 14:23:32 -070010
11The example code for this and our other examples lives in the `grpc-common`
12GitHub repository. Clone this repository to your local machine by running the
13following command:
14
15
16```sh
17$ git clone https://github.com/grpc/grpc-common.git
18```
19
murgatroid993ea5cc92015-06-12 16:06:37 -070020Change your current directory to `grpc-common/objective-c/helloworld`
murgatroid99042b9122015-06-11 14:23:32 -070021
22```sh
murgatroid993ea5cc92015-06-12 16:06:37 -070023$ cd grpc-common/objective-c/helloworld
murgatroid99042b9122015-06-11 14:23:32 -070024```
25
26### Try it!
27To 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
36Now have Cocoapods generate and install the client library for our .proto files:
37
38```shell
39$ pod install
40```
41
42This might have to compile OpenSSL, which takes around 15 minutes if Cocoapods doesn't have it yet on your computer's cache).
43
murgatroid993ea5cc92015-06-12 16:06:37 -070044Finally, open the XCode workspace created by Cocoapods, and run the app. You can check the calling code in `main.m` and see the results in XCode's log console.
murgatroid99042b9122015-06-11 14:23:32 -070045
murgatroid995de22f52015-06-12 11:21:55 -070046The 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
murgatroid99042b9122015-06-11 14:23:32 -070048## Tutorial
49
murgatroid995de22f52015-06-12 11:21:55 -070050You 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)