Update ios-app.md
Move from git_repository to http_archive and add more details to the documentation.
Will update bazelbuild/examples with https://github.com/bazelbuild/examples/pull/44
Closes #3968.
PiperOrigin-RevId: 176113916
diff --git a/site/docs/tutorial/ios-app.md b/site/docs/tutorial/ios-app.md
index 44d6bca..605d94f 100644
--- a/site/docs/tutorial/ios-app.md
+++ b/site/docs/tutorial/ios-app.md
@@ -40,9 +40,9 @@
### Install Xcode
-Download and install [Xcode](https://developer.apple.com/xcode/downloads/). The
-Xcode download contains the iOS libraries, the Objective-C compiler, and other
-tools required by Bazel to build iOS apps.
+Download and install [Xcode](https://developer.apple.com/xcode/downloads/).
+Xcode contains the compilers, SDKs, and other tools required by Bazel to build
+Apple applications.
### Get the sample project
@@ -78,9 +78,9 @@
workspace directory is `$HOME/examples/tutorial/`, which contains the sample
project files you cloned from the GitHub repo in the previous step.
-Note that Bazel itself doesn't make any requirements about how you organize
-source files in your workspace. The sample source files in this tutorial are
-organized according to conventions for the target platform.
+Note that Bazel itself doesn't impose any requirements for organizing source
+files in your workspace. The sample source files in this tutorial are organized
+according to conventions for the target platform.
For your convenience, set the `$WORKSPACE` environment variable now to refer to
your workspace directory. At the command line, enter:
@@ -104,24 +104,32 @@
```bash
touch $WORKSPACE/WORKSPACE
+open -a Xcode $WORKSPACE/WORKSPACE
```
-This creates the empty `WORKSPACE` file.
+This creates and opens the empty `WORKSPACE` file.
### Update the WORKSPACE file
To build applications for Apple devices, Bazel needs to pull the latest
[Apple build rules](https://github.com/bazelbuild/rules_apple) from its GitHub
-repository. To enable this, add the following to your `WORKSPACE` file:
+repository. To enable this, add the following [`http_archive`](../be/workspace.html#http_archive)
+rule to your `WORKSPACE` file:
```
-git_repository(
+http_archive(
name = "build_bazel_rules_apple",
- remote = "https://github.com/bazelbuild/rules_apple.git",
- commit = "7ea0557",
+ strip_prefix = "rules_apple-0.1.0",
+ urls = ["https://github.com/bazelbuild/rules_apple/archive/0.1.0.tar.gz"],
)
```
+**NOTE:** "Always use the [latest version of the build_apple rules](https://github.com/bazelbuild/rules_apple/releases)
+in the `urls` and `strip_prefix` attributes."
+
+**NOTE:** You **must** set the value of the `name` attribute in the
+`http_archive` rule to `build_bazel_rules_apple` or the build will fail.
+
## Review the source files
Take a look at the source files for the app located in
@@ -131,10 +139,11 @@
## Create a BUILD file
-At a command-line prompt, open your new `BUILD` file for editing:
+At a command-line prompt, open a new `BUILD` file for editing:
```bash
-vi $WORKSPACE/ios-app/BUILD
+touch $WORKSPACE/ios-app/BUILD
+open -a Xcode $WORKSPACE/ios-app/BUILD
```
### Add the rule load statement
@@ -147,6 +156,9 @@
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application")
```
+We only need to load the `ios_application` rule because the `objc_library` rule
+is built into the Bazel package.
+
### Add an objc_library rule
Bazel provides several build rules that you can use to build an app for the
@@ -192,12 +204,16 @@
"iphone",
"ipad",
],
+ minimum_os_version = "9.0"
infoplists = [":UrlGet/UrlGet-Info.plist"],
visibility = ["//visibility:public"],
deps = [":UrlGetClasses"],
)
```
+**NOTE:** Please update the `minimum_os_version` attribute to the minimum
+version of iOS that you plan to support.
+
Note how the `deps` attribute references the output of the `UrlGetClasses` rule
you added to the `BUILD` file above.
@@ -246,6 +262,7 @@
### Run and debug the app in the simulator
You can now run the app from Xcode using the iOS Simulator. First, [generate an Xcode project using Tulsi](http://tulsi.bazel.io/).
+
Then, open the project in Xcode, choose an iOS Simulator as the runtime scheme,
and click **Run**.