From b3b736fa59ece97ac9f5be821b82e3be5d9cf8a9 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 18 Sep 2019 10:36:55 -0700 Subject: [PATCH] Merge examples/objectivec/README into Hello World's README --- examples/objective-c/README.md | 60 ----------------------- examples/objective-c/helloworld/README.md | 53 +++++++++++++++++++- 2 files changed, 51 insertions(+), 62 deletions(-) delete mode 100644 examples/objective-c/README.md diff --git a/examples/objective-c/README.md b/examples/objective-c/README.md deleted file mode 100644 index 36e6f8b1a01..00000000000 --- a/examples/objective-c/README.md +++ /dev/null @@ -1,60 +0,0 @@ -# gRPC in 3 minutes (Objective-C with Bazel) - -To save you from reading, if you use Cocoapods and Xcode, the right reference for you is in the [Hello World](helloworld) example directory. - -## Background -There are currently two ways to build projects with the gRPC Objective-C library: -* Cocoapods & Xcode -* Bazel - -The [helloworld](helloworld) sample is the entry point for the Cocoapods way of building projects. More is documented on grpc.io, including [installation](https://grpc.io/docs/quickstart/objective-c/) and some [tutorials](https://grpc.io/docs/tutorials/basic/objective-c/). They will not be reiterated here and they are not mandatory for the Bazel way. - -A good place to get started with Bazel is their official [website](https://bazel.build). The documentation of using gRPC Objective-C library with Bazel is [here](https://github.com/grpc/proposal/blob/master/L56-objc-bazel-support.md). - -## Installation -To run the examples in Bazel, you should have [Bazel](https://docs.bazel.build/versions/master/install-os-x.html) installed. - -## Hello Objective-C gRPC! -Here's how to build and run the Objective-C implementation of the [Hello World](helloworld) example. - -The code for the Hello World example and others live in the `examples` directory. Clone this repository to your local machine by running the following commands: -```shell -$ git clone --recursive https://github.com/grpc/grpc -``` - -Next, change your directory to `examples/objective-c` -```shell -$ cd examples/objective-c -``` - -### Try it! -To run the Hello World sample properly, we need a local server. Let's compile and run the corresponding C++ server: -```shell -$ pushd ../cpp/helloworld -$ make -$ ./greeter_server & -$ popd -``` -Or do it the Bazel way (you might need to open another shell tab for this): -```shell -$ bazel run //examples:greeter_server -``` - -Now compile the sample: -```shell -$ bazel build :HelloWorld -``` -To run the sample, you need to know the available simulator runtimes in your machine. You could either list the available runtimes yourself by running: -```shell -$ xcrun simctl list -``` -Or just try running the app and it will let you know what is available in the error messages: -```shell -$ bazel run :HelloWorld -``` -Note that running this command will build the project even if it is not built beforehand. - -Finally, launch the app with one of the available runtimes: -```shell -$ bazel run :HelloWorld --ios_simulator_version='' --ios_sumlator_device='' -``` diff --git a/examples/objective-c/helloworld/README.md b/examples/objective-c/helloworld/README.md index 2fe9913c96b..7a7516a3dca 100644 --- a/examples/objective-c/helloworld/README.md +++ b/examples/objective-c/helloworld/README.md @@ -1,12 +1,18 @@ # gRPC in 3 minutes (Objective-C) +There are currently two ways to build projects with the gRPC Objective-C library: +* Cocoapods & Xcode +* Bazel (experimental) + +## Cocoapods + ## Installation 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). -## Hello Objective-C gRPC! +### Hello Objective-C gRPC! Here's how to build and run the Objective-C implementation of the [Hello World](../../protos/helloworld.proto) example used in [Getting started](https://github.com/grpc/grpc/tree/master/examples). @@ -27,7 +33,7 @@ Change your current directory to `examples/objective-c/helloworld` $ cd examples/objective-c/helloworld ``` -### Try it! +#### Try it! 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: @@ -53,6 +59,49 @@ code in `main.m` and see the results in XCode's log console. 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. +## Bazel +### Installation +To run the examples in Bazel, you should have [Bazel](https://docs.bazel.build/versions/master/install-os-x.html) installed. + +### Hello Objective-C gRPC! +Here's how to build and run the Objective-C implementation of the [Hello World](helloworld) example. + +The code for the Hello World example and others live in the `examples` directory. Clone this repository to your local machine by running the following commands: +```shell +$ git clone --recursive https://github.com/grpc/grpc +``` + +Next, change your directory to `examples/objective-c` +```shell +$ cd grpc/examples/objective-c +``` + +Now build the Hello World project: +```shell +$ bazel build :HelloWorld +``` + +#### Try it! +To run the Hello World sample properly, we need a local server. Let's compile and run the corresponding C++ server: +```shell +$ bazel run //examples:greeter_server +``` + +To run the sample, you need to know the available simulator runtimes in your machine. You could either list the available runtimes yourself by running: +```shell +$ xcrun simctl list +``` +Or just try running the app and it will let you know what is available in the error messages: +```shell +$ bazel run :HelloWorld +``` +Note that running this command will build the project even if it is not built beforehand. + +Finally, launch the app with one of the available runtimes: +```shell +$ bazel run :HelloWorld --ios_simulator_version='' --ios_sumlator_device='' +``` + ## Tutorial You can find a more detailed tutorial in [gRPC Basics: Objective-C](https://grpc.io/docs/tutorials/basic/objective-c.html).