| OLD | NEW |
| 1 # iOS Build Instructions | 1 # iOS Build Instructions |
| 2 | 2 |
| 3 **Note:** Upstreaming of iOS code is still a work in progress. In particular, | 3 **Note:** Upstreaming of iOS code is still a work in progress. In particular, |
| 4 note that **it is not currently possible to build an actual Chromium app.** | 4 note that **it is not currently possible to build an actual Chromium app.** |
| 5 Currently, the buildable binaries are ios\_web\_shell (a minimal wrapper around | 5 Currently, the buildable binaries are ios\_web\_shell (a minimal wrapper around |
| 6 the web layer), and various unit tests. | 6 the web layer), and various unit tests. |
| 7 | 7 |
| 8 ## Prerequisites | 8 ## Prerequisites |
| 9 | 9 |
| 10 * A Mac with a version of OS X capable of running the latest version | 10 * A Mac running 10.11+. |
| 11 of Xcode. | 11 * [Xcode] 8.0+. |
| 12 * The latest version of [Xcode](https://developer.apple.com/xcode/), | 12 * [depot\_tools]. |
| 13 including the current iOS SDK. | |
| 14 * The current version of the JDK (required for the closure compiler). | 13 * The current version of the JDK (required for the closure compiler). |
| 15 * [depot\_tools](http://dev.chromium.org/developers/how-tos/install-depot-tool
s). | |
| 16 | 14 |
| 17 ## Setting Up | 15 ## Getting the source |
| 18 | 16 |
| 19 ### With GYP | 17 To checkout the source, use `fetch ios` command from [depot\_tools] in a new |
| 20 | 18 empty directory. |
| 21 In the directory where you are going to check out the code, create a | |
| 22 `chromium.gyp_env` to set the build to use iOS targets (and to use | |
| 23 hybrid builds; see [Building](#Building) below): | |
| 24 | 19 |
| 25 ```shell | 20 ```shell |
| 26 cat > chromium.gyp_env <<EOF | 21 # You can use a different location for your checkout of Chromium on iOS |
| 27 { | 22 # by updating this variable. All shell snippets will refer to it. |
| 28 "GYP_DEFINES": "OS=ios", | 23 CHROMIUM_IOS="$HOME/chromium_ios" |
| 29 "GYP_GENERATORS": "ninja,xcode-ninja", | 24 mkdir "$CHROMIUM_IOS" |
| 30 } | 25 cd "$CHROMIUM_IOS" |
| 31 EOF | |
| 32 ``` | |
| 33 | |
| 34 If you aren't set up to sign iOS build products via a developer account, | |
| 35 you should instead use: | |
| 36 | |
| 37 ```shell | |
| 38 cat > chromium.gyp_env <<EOF | |
| 39 { | |
| 40 "GYP_DEFINES": "OS=ios chromium_ios_signing=0", | |
| 41 "GYP_GENERATORS": "ninja,xcode-ninja", | |
| 42 } | |
| 43 EOF | |
| 44 ``` | |
| 45 | |
| 46 ### With GN | |
| 47 | |
| 48 Use `gn args out/Debug-iphonesimulator` (or replace | |
| 49 `out/Debug-iphonesimulator` with your chosen `out/` directory) to open up an | |
| 50 editor to set the following gn variables and regenerate: | |
| 51 | |
| 52 ``` | |
| 53 # Set to true if you have a valid code signing key. | |
| 54 ios_enable_code_signing = false | |
| 55 target_os = "ios" | |
| 56 # Set to "x86", "x64", "arm", "armv7", "arm64". "x86" and "x64" will create a | |
| 57 # build to run on the iOS simulator (and set use_ios_simulator = true), all | |
| 58 # others are for an iOS device. | |
| 59 target_cpu = "x64" | |
| 60 # Release vs debug build. | |
| 61 is_debug = true | |
| 62 ``` | |
| 63 | |
| 64 ### API Keys | |
| 65 | |
| 66 Before you build, you may want to | |
| 67 [install API keys](https://sites.google.com/a/chromium.org/dev/developers/how-to
s/api-keys) | |
| 68 so that Chrome-integrated Google services work. This step is optional if you | |
| 69 aren't testing those features. | |
| 70 | |
| 71 ## Getting the Code | |
| 72 | |
| 73 Next, [check out the | |
| 74 code](https://www.chromium.org/developers/how-tos/get-the-code), with: | |
| 75 | |
| 76 ```shell | |
| 77 fetch ios | 26 fetch ios |
| 78 ``` | 27 ``` |
| 79 | 28 |
| 80 ## Building | 29 ## Setting up |
| 81 | 30 |
| 82 Build the target you are interested in. The instructions above select | 31 Chromium on iOS is built using the [Ninja](ninja_build.md) tool and |
| 83 the ninja/Xcode hybrid mode, which uses ninja to do the actual build, | 32 the [Clang](clang.md) compiler. See both of those pages for further details on |
| 84 but provides a wrapper Xcode project that can be used to build targets | 33 how to tune the build. |
| 85 and navigate the source. (The Xcode project just shells out to ninja to | 34 |
| 86 do the builds, so you can't actually inspect/change target-level | 35 Before you build, you may want to [install API keys](api-keys) so that |
| 87 settings from within Xcode; this mode avoids generating a large tree of | 36 Chrome-integrated Google services work. This step is optional if you aren't |
| 88 Xcode projects, which leads to performance issues in Xcode). To build | 37 testing those features. |
| 89 with ninja (simulator and device, respectively): | 38 |
| 39 ### Quick setup |
| 40 |
| 41 To setup the repository for building Chromium on iOS code, it is recommended |
| 42 to use the `src/ios/build/tools/setup-gn.py` script that creates a Xcode |
| 43 workspace configured to build the different targets for device and simulator. |
| 90 | 44 |
| 91 ```shell | 45 ```shell |
| 92 ninja -C out/Debug-iphonesimulator All | 46 cd "$CHROMIUM_IOS/src" |
| 93 ninja -C out/Debug-iphoneos All | 47 ios/build/tools/setup-gn.py |
| 48 open out/build/all.xcworkspace |
| 94 ``` | 49 ``` |
| 95 | 50 |
| 96 To build with Xcode, open `build/all.ninja.xcworkspace`, and choose the | 51 You can customize the build by editing the file `$HOME/.setup-gn` (create it |
| 97 target you want to build. | 52 if it does not exists). Look at `src/ios/build/tools/setup-gn.config` for |
| 53 available configuration options. |
| 98 | 54 |
| 99 You should always be able to build All, since targets are added there for iOS | 55 From this point, you can either build from Xcode or from the command-line |
| 100 only when they compile. | 56 using `ninja`. The script `setup-gn.py` creates sub-directories named |
| 57 `out/${configuration}-${platform}`, so for a `Debug` build for simulator |
| 58 use: |
| 59 |
| 60 ```shell |
| 61 ninja -C out/Debug-iphonesimulator gn_all |
| 62 ``` |
| 63 |
| 64 Note: you need to run `setup-gn.py` script every time one of the `BUILD.gn` |
| 65 file is updated (either by you or after rebasing). If you forget to run it, |
| 66 the list of targets and files in the Xcode solution may be stale. |
| 67 |
| 68 ### Advanced setup |
| 69 |
| 70 You can run `gn` manually to configure the build yourself. In that case, |
| 71 refer to [mac build instructions] for help on how to do that. |
| 72 |
| 73 To build for iOS, you have to set `target_os` to `"ios"`. Please also note |
| 74 that `is_component_build` is not supported when building for iOS and must |
| 75 be set to `false`. |
| 101 | 76 |
| 102 ## Running | 77 ## Running |
| 103 | 78 |
| 104 Any target that is built and runs on the bots (see [below](#Troubleshooting)) | 79 Any target that is built and runs on the bots (see [below](#Troubleshooting)) |
| 105 should run successfully in a local build. As of the time of writing, this is | 80 should run successfully in a local build. As of the time of writing, this is |
| 106 only ios\_web\_shell and unit test targets—see the note at the top of this | 81 only ios\_web\_shell and unit test targets—see the note at the top of this |
| 107 page. Check the bots periodically for updates; more targets (new components) | 82 page. Check the bots periodically for updates; more targets (new components) |
| 108 will come on line over time. | 83 will come on line over time. |
| 109 | 84 |
| 110 To run in the simulator from the command line, you can use `iossim`. For | 85 To run in the simulator from the command line, you can use `iossim`. For |
| 111 example, to run a debug build of ios\_web\_shell: | 86 example, to run a debug build of ios\_web\_shell: |
| 112 | 87 |
| 113 ```shell | 88 ```shell |
| 114 out/Debug-iphonesimulator/iossim out/Debug-iphonesimulator/ios_web_shell.app | 89 out/Debug-iphonesimulator/iossim out/Debug-iphonesimulator/ios_web_shell.app |
| 115 ``` | 90 ``` |
| 116 | 91 |
| 117 ## Converting an existing Mac checkout into an iOS checkout | |
| 118 | |
| 119 If you want to convert your Mac checkout into an iOS checkout, follow the steps | |
| 120 below: | |
| 121 | |
| 122 1. Add `target_os = [ "ios" ]` to the bottom of your `chromium/.gclient` | |
| 123 file. | |
| 124 | |
| 125 2. For gyp, make sure you have the following in your | |
| 126 `chromium/chromium.gyp_env` file (removing the `chromium_ios_signing=0` if you | |
| 127 want to make developer-signed builds): | |
| 128 | |
| 129 ```json | |
| 130 { | |
| 131 "GYP_DEFINES" : "OS=ios chromium_ios_signing=0", | |
| 132 "GYP_GENERATORS" : "ninja,xcode-ninja", | |
| 133 } | |
| 134 ``` | |
| 135 | |
| 136 For gn, add the arguments specified [above](#With-GN) to your gn setup. | |
| 137 | |
| 138 3. Make sure to sync again to fetch the iOS specific dependencies and | |
| 139 regenerate build rules using: | |
| 140 | |
| 141 ```shell | |
| 142 gclient sync | |
| 143 ``` | |
| 144 | |
| 145 ## Troubleshooting | 92 ## Troubleshooting |
| 146 | 93 |
| 147 If your build fails, check the iOS columns of [the Mac | 94 If your build fails, check the iOS columns of [the Mac |
| 148 waterfall](http://build.chromium.org/p/chromium.mac/console) (the last two) to | 95 waterfall](http://build.chromium.org/p/chromium.mac/console) (the last two) to |
| 149 see if the bots are green. In general they should be, since failures on those | 96 see if the bots are green. In general they should be, since failures on those |
| 150 bots will close the tree. | 97 bots will close the tree. |
| 98 |
| 99 [Xcode]: https://developer.apple.com/xcode |
| 100 [depot\_tools]: https://dev.chromium.org/developers/how-tos/depottools |
| 101 [Ninja]: ninja.md |
| 102 [Clang]: clang.md |
| 103 [api-keys]: https://sites.google.com/a/chromium.org/dev/developers/how-tos/api-k
eys |
| 104 [mac build instructions]: mac_build_instructions.md |
| OLD | NEW |