blob: cb25882867c6a30520672c5bd32918d36822df40 [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
murgatroid995de22f52015-06-12 11:21:55 -070020Change your current directory to `grpc-common/objective-c/HelloWorld`
murgatroid99042b9122015-06-11 14:23:32 -070021
22```sh
23$ cd grpc-common/objective-c/HelloWorld
24```
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
44Finally, 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
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)