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