ios_build_instructions.md 5.83 KB
Newer Older
1
# iOS Build Instructions
2

3
**See also [the old version of this page](old_ios_build_instructions.md).**
4

5
Google employee? See [go/building-chrome](https://goto.google.com/building-chrome) instead.
6

7
[TOC]
8

9
## System requirements
10

11 12
* A 64-bit Mac running 10.11+.
* [Xcode](https://developer.apple.com/xcode) 8.0+.
13 14 15 16 17
* The OS X 10.10 SDK. Run

    ```shell  
    $ ls `xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs
    ```
18 19 20
 
  to check whether you have it.  Building with the 10.11 SDK works too, but
  the releases currently use the 10.10 SDK.
21
* The current version of the JDK (required for the Closure compiler).
22

23
## Install `depot_tools`
24

25
Clone the `depot_tools` repository:
26

27 28 29
```shell
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
```
30

31 32 33
Add `depot_tools` to the end of your PATH (you will probably want to put this
in your `~/.bashrc` or `~/.zshrc`). Assuming you cloned `depot_tools` to
`/path/to/depot_tools`:
34

35 36 37
```shell
$ export PATH="$PATH:/path/to/depot_tools"
```
38

39
## Get the code
40

41
Create a `chromium` directory for the checkout and change to it (you can call
42 43 44
this whatever you like and put it wherever you like, as
long as the full path has no spaces):

45 46 47
```shell
$ mkdir chromium && cd chromium
```
48

49 50
Run the `fetch` tool from `depot_tools` to check out the code and its
dependencies.
51

52 53 54
```shell
$ fetch ios
```
55 56

If you don't want the full repo history, you can save a lot of time by
57 58 59 60
adding the `--no-history` flag to `fetch`.

Expect the command to take 30 minutes on even a fast connection, and many
hours on slower ones.
61

62 63 64
When `fetch` completes, it will have created a hidden `.gclient` file and a
directory called `src` in the working directory. The remaining instructions
assume you have switched to the `src` directory:
65

66 67 68
```shell
$ cd src
```
69

70 71 72 73
*Optional*: You can also [install API
keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your
build to talk to some Google services, but this is not necessary for most
development and testing purposes.
74 75 76

## Setting up the build

77 78 79 80
Since the iOS build is a bit more complicated than a desktop build, we provide
`ios/build/tools/setup-gn.py`, which will create four appropriately configured
build directories under `out` for Release and Debug device and simulator
builds, and generates an appropriate Xcode workspace as well. 
81 82

This script is run automatically by fetch (as part of `gclient runhooks`).
83

84 85
You can customize the build by editing the file `$HOME/.setup-gn` (create it if
it does not exist).  Look at `src/ios/build/tools/setup-gn.config` for
86
available configuration options.
87

88 89 90
From this point, you can either build from Xcode or from the command line using
`ninja`. `setup-gn.py` creates sub-directories named
`out/${configuration}-${platform}`, so for a `Debug` build for simulator use:
91

92
```shell
93
$ ninja -C out/Debug-iphonesimulator gn_all
94
```
95

96 97 98
Note: you need to run `setup-gn.py` script every time one of the `BUILD.gn`
file is updated (either by you or after rebasing). If you forget to run it,
the list of targets and files in the Xcode solution may be stale.
99

100
You can also follow the manual instructions on the 
101
[Mac page](mac_build_instructions.md), but make sure you set the
102
GN arg `target_os="ios"`.
103

104
## Running
105

106 107
Any target that is built and runs on the bots (see [below](#Troubleshooting))
should run successfully in a local build. As of the time of writing, this is
108 109 110
only the `ios_web_shell` and `ios_chrome_unittests` targets—see the note at the
top of this page. Check the bots periodically for updates; more targets (new
components) will come on line over time.
111 112

To run in the simulator from the command line, you can use `iossim`. For
113
example, to run a debug build of `ios_web_shell`:
114

115
```shell
116
$ out/Debug-iphonesimulator/iossim out/Debug-iphonesimulator/ios_web_shell.app
117
```
118

119 120 121 122
## Update your checkout

To update an existing checkout, you can run

123 124 125 126
```shell
$ git rebase-update
$ gclient sync
```
127 128

The first command updates the primary Chromium source repository and rebases
129 130 131
any of your local branches on top of tip-of-tree (aka the Git branch
`origin/master`). If you don't want to use this script, you can also just use
`git pull` or other common Git commands to update the repo.
132

133 134
The second command syncs dependencies to the appropriate versions and re-runs
hooks as needed.
135 136 137 138 139 140 141 142 143 144 145

## Tips, tricks, and troubleshooting

If you have problems building, join us in `#chromium` on `irc.freenode.net` and
ask there. As mentioned above, be sure that the
[waterfall](http://build.chromium.org/buildbot/waterfall/) is green and the tree
is open before checking out. This will increase your chances of success.

### Improving performance of `git status`

`git status` is used frequently to determine the status of your checkout.  Due
146 147 148
to the large number of files in Chromium's checkout, `git status` performance
can be quite variable.  Increasing the system's vnode cache appears to help.
By default, this command:
149

150 151 152
```shell
$ sysctl -a | egrep kern\..*vnodes
```
153 154 155 156

Outputs `kern.maxvnodes: 263168` (263168 is 257 * 1024).  To increase this
setting:

157 158 159
```shell
$ sudo sysctl kern.maxvnodes=$((512*1024))
```
160 161 162 163 164

Higher values may be appropriate if you routinely move between different
Chromium checkouts.  This setting will reset on reboot, the startup setting can
be set in `/etc/sysctl.conf`:

165 166 167
```shell
$ echo kern.maxvnodes=$((512*1024)) | sudo tee -a /etc/sysctl.conf
```
168 169 170

Or edit the file directly.

171
If `git --version` reports 2.6 or higher, the following may also improve
172 173
performance of `git status`:

174 175 176
```shell
$ git update-index --untracked-cache
```
177 178 179 180 181

### Xcode license agreement

If you're getting the error

182 183
> Agreeing to the Xcode/iOS license requires admin privileges, please re-run as
> root via sudo.
184 185 186 187

the Xcode license hasn't been accepted yet which (contrary to the message) any
user can do by running:

188 189 190
```shell
$ xcodebuild -license
```
191

192
Only accepting for all users of the machine requires root:
193

194 195 196
```shell
$ sudo xcodebuild -license
```