michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 1 | # Checking out and building Chromium for iOS |
| 2 | |
| 3 | There are instructions for other platforms linked from the |
| 4 | [get the code](../get_the_code.md) page. |
| 5 | |
| 6 | ## Instructions for Google Employees |
| 7 | |
| 8 | Are you a Google employee? See |
| 9 | [go/building-chrome](https://goto.google.com/building-chrome) instead. |
| 10 | |
| 11 | [TOC] |
| 12 | |
| 13 | ## System requirements |
| 14 | |
Sylvain Defresne | 09a1b99 | 2025-01-08 15:02:39 | [diff] [blame] | 15 | <!-- LINT.IfChange --> |
Sylvain Defresne | 1a98f76 | 2025-01-07 14:08:50 | [diff] [blame] | 16 | |
Sylvain Defresne | 991d8e2 | 2023-11-29 17:15:30 | [diff] [blame] | 17 | * A 64-bit Mac capable of running the required version of Xcode. |
Justin Cohen | 9a1c777 | 2024-10-01 21:37:41 | [diff] [blame] | 18 | * [Xcode](https://developer.apple.com/xcode) 16.0 or higher. |
Sylvain Defresne | 991d8e2 | 2023-11-29 17:15:30 | [diff] [blame] | 19 | |
Sylvain Defresne | 09a1b99 | 2025-01-08 15:02:39 | [diff] [blame] | 20 | <!-- LINT.ThenChange(//ios/build/chrome_build.gni) --> |
| 21 | |
Sylvain Defresne | 991d8e2 | 2023-11-29 17:15:30 | [diff] [blame] | 22 | Note: after installing Xcode, you need to launch it and to let it install |
| 23 | the iOS simulator. This is required as part of the build, see [this discussion]( |
| 24 | https://groups.google.com/a/chromium.org/g/chromium-dev/c/98d6MyLoYHM/m/A_HyOGxPAgAJ) |
| 25 | on chromium-dev. |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 26 | |
| 27 | ## Install `depot_tools` |
| 28 | |
| 29 | Clone the `depot_tools` repository: |
| 30 | |
| 31 | ```shell |
| 32 | $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git |
| 33 | ``` |
| 34 | |
Sylvain Defresne | 2522b84 | 2025-03-11 19:10:24 | [diff] [blame] | 35 | You need to add the directory where you checked out `depot_tools` to your |
| 36 | `PATH` to make the `gclient` commands available. It is also recommended to |
| 37 | add the `depot_tools/python-bin` directory to your `PATH` to get access to |
| 38 | a recent version of python3 (the version shipped by default on macOS tends |
| 39 | to be quite old which can lead to build failure). |
| 40 | |
| 41 | To do that, edit your shell login script (e.g. `~/.bash_profile`, `~/.zprofile`) |
| 42 | and add the following line at the end (assuming you've checked out `depot_tools` |
| 43 | in your `HOME` directory): |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 44 | |
| 45 | ```shell |
Sylvain Defresne | 2522b84 | 2025-03-11 19:10:24 | [diff] [blame] | 46 | export PATH="$HOME/depot_tools:$HOME/depot_tools/python-bin:$PATH" |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 47 | ``` |
| 48 | |
Sylvain Defresne | 2522b84 | 2025-03-11 19:10:24 | [diff] [blame] | 49 | You may need to run `gclient status` to force an update of `depot_tools` |
| 50 | before the `python3` command work once you've updated your `PATH`. |
| 51 | |
| 52 | You can omit `$HOME/depot_tools/python-bin` if you already have a recent |
| 53 | version of python installed and you manually manage it (but this may lead |
| 54 | to unexpected build failures). |
| 55 | |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 56 | ## Get the code |
| 57 | |
| 58 | Create a `chromium` directory for the checkout and change to it (you can call |
| 59 | this whatever you like and put it wherever you like, as |
| 60 | long as the full path has no spaces): |
| 61 | |
| 62 | ```shell |
| 63 | $ mkdir chromium && cd chromium |
| 64 | ``` |
| 65 | |
| 66 | Run the `fetch` tool from `depot_tools` to check out the code and its |
| 67 | dependencies. |
| 68 | |
| 69 | ```shell |
| 70 | $ fetch ios |
| 71 | ``` |
| 72 | |
| 73 | If you don't want the full repo history, you can save a lot of time by |
| 74 | adding the `--no-history` flag to `fetch`. |
| 75 | |
| 76 | Expect the command to take 30 minutes on even a fast connection, and many |
| 77 | hours on slower ones. |
| 78 | |
| 79 | When `fetch` completes, it will have created a hidden `.gclient` file and a |
| 80 | directory called `src` in the working directory. The remaining instructions |
| 81 | assume you have switched to the `src` directory: |
| 82 | |
| 83 | ```shell |
| 84 | $ cd src |
| 85 | ``` |
| 86 | |
| 87 | *Optional*: You can also [install API |
| 88 | keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your |
| 89 | build to talk to some Google services, but this is not necessary for most |
| 90 | development and testing purposes. |
| 91 | |
| 92 | ## Setting up the build |
| 93 | |
| 94 | Since the iOS build is a bit more complicated than a desktop build, we provide |
| 95 | `ios/build/tools/setup-gn.py`, which will create four appropriately configured |
| 96 | build directories under `out` for Release and Debug device and simulator |
Sylvain Defresne | fc11bcd | 2020-06-26 13:42:00 | [diff] [blame] | 97 | builds, and generates an appropriate Xcode project (`out/build/all.xcodeproj`) |
| 98 | as well. |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 99 | |
Sylvain Defresne | fc11bcd | 2020-06-26 13:42:00 | [diff] [blame] | 100 | More information about [developing with Xcode](xcode_tips.md). *Xcode project |
| 101 | is an artifact, any changes made in the project itself will be ignored.* |
Mike Dougherty | d8947a59 | 2020-05-07 19:43:46 | [diff] [blame] | 102 | |
Raphael Kubo da costa | 47cb107 | 2024-12-11 18:37:29 | [diff] [blame] | 103 | You can customize the build by editing a file called `.setup-gn` (create it if |
| 104 | it does not exist). It can be stored in two locations: |
| 105 | |
| 106 | * `$HOME/.setup-gn` (the settings will be applied to all Chromium checkouts). |
| 107 | * The directory above `src/` (i.e. the directory containing your `.gclient`) |
| 108 | for checkout-specific settings. |
| 109 | |
| 110 | Look at `src/ios/build/tools/setup-gn.config` for available configuration |
| 111 | options. |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 112 | |
| 113 | From this point, you can either build from Xcode or from the command line using |
Dirk Pranke | 8bd55f2 | 2018-10-24 21:22:10 | [diff] [blame] | 114 | `autoninja`. `setup-gn.py` creates sub-directories named |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 115 | `out/${configuration}-${platform}`, so for a `Debug` build for simulator use: |
| 116 | |
| 117 | ```shell |
Dirk Pranke | 8bd55f2 | 2018-10-24 21:22:10 | [diff] [blame] | 118 | $ autoninja -C out/Debug-iphonesimulator gn_all |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 119 | ``` |
| 120 | |
Dirk Pranke | 8bd55f2 | 2018-10-24 21:22:10 | [diff] [blame] | 121 | (`autoninja` is a wrapper that automatically provides optimal values for the |
| 122 | arguments passed to `ninja`.) |
| 123 | |
Mike Dougherty | d8947a59 | 2020-05-07 19:43:46 | [diff] [blame] | 124 | Note: The `setup-gn.py` script needs to run every time one of the `BUILD.gn` |
| 125 | files is updated (either by you or after rebasing). If you forget to run it, |
| 126 | the list of targets and files in the Xcode solution may be stale. You can run |
| 127 | the script directly or use either `gclient sync` or `gclient runhooks` which |
| 128 | will run `setup-gn.py` for you as part of the update hooks. |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 129 | |
Sylvain Defresne | 9932328e | 2020-07-09 10:44:40 | [diff] [blame] | 130 | You can add a custom hook to `.gclient` file to configure `setup-gn.py` to |
| 131 | be run as part of `gclient runhooks`. In that case, your `.gclient` file |
| 132 | would look like this: |
| 133 | |
| 134 | ``` |
| 135 | solutions = [ |
| 136 | { |
| 137 | "name" : "src", |
| 138 | "url" : "https://chromium.googlesource.com/chromium/src.git", |
| 139 | "deps_file" : "DEPS", |
| 140 | "managed" : False, |
| 141 | "custom_deps" : {}, |
| 142 | "custom_vars" : {}, |
| 143 | "custom_hooks": [{ |
| 144 | "name": "setup_gn", |
| 145 | "pattern": ".", |
| 146 | "action": [ |
Takuto Ikuta | d36eb35 | 2022-03-01 01:39:48 | [diff] [blame] | 147 | "python3", |
Sylvain Defresne | 9932328e | 2020-07-09 10:44:40 | [diff] [blame] | 148 | "src/ios/build/tools/setup-gn.py", |
| 149 | ] |
| 150 | }], |
| 151 | "safesync_url": "", |
| 152 | }, |
| 153 | ] |
| 154 | target_os = ["ios"] |
| 155 | target_os_only = True |
| 156 | ``` |
| 157 | |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 158 | You can also follow the manual instructions on the |
| 159 | [Mac page](../mac_build_instructions.md), but make sure you set the |
| 160 | GN arg `target_os="ios"`. |
| 161 | |
Andrew Williams | 54da9cc | 2024-01-09 17:32:23 | [diff] [blame] | 162 | ### Faster builds |
| 163 | |
| 164 | This section contains some things you can change to speed up your builds, |
| 165 | sorted so that the things that make the biggest difference are first. |
| 166 | |
| 167 | #### Use Reclient |
| 168 | |
| 169 | Google employees should use Reclient, a distributed compilation system. Detailed |
| 170 | information is available internally but the relevant gn arg is: |
| 171 | * `use_remoteexec = true` |
| 172 | |
| 173 | Google employees can visit |
| 174 | [go/building-chrome-mac#using-remote-execution](https://goto.google.com/building-chrome-mac#using-remote-execution) |
| 175 | for more information. For external contributors, Reclient does not support iOS |
| 176 | builds. |
| 177 | |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 178 | ## Building for device |
| 179 | |
| 180 | To be able to build and run Chromium and the tests for devices, you need to |
| 181 | have an Apple developer account (a free one will work) and the appropriate |
| 182 | provisioning profiles, then configure the build to use them. |
| 183 | |
| 184 | ### Code signing identity |
| 185 | |
| 186 | Please refer to the Apple documentation on how to get a code signing identity |
| 187 | and certificates. You can check that you have a code signing identity correctly |
| 188 | installed by running the following command. |
| 189 | |
| 190 | ```shell |
| 191 | $ xcrun security find-identity -v -p codesigning |
| 192 | 1) 0123456789ABCDEF0123456789ABCDEF01234567 "iPhone Developer: [email protected] (XXXXXXXXXX)" |
| 193 | 1 valid identities found |
| 194 | ``` |
| 195 | |
| 196 | If the command output says you have zero valid identities, then you do not |
| 197 | have a code signing identity installed and need to get one from Apple. If |
| 198 | you have more than one identity, the build system may select the wrong one |
| 199 | automatically, and you can use the `ios_code_signing_identity` gn variable |
| 200 | to control which one to use by setting it to the identity hash, e.g. to |
| 201 | `"0123456789ABCDEF0123456789ABCDEF01234567"`. |
| 202 | |
| 203 | ### Mobile provisioning profiles |
| 204 | |
| 205 | Once you have the code signing identity, you need to decide on a prefix |
| 206 | for the application bundle identifier. This is controlled by the gn variable |
| 207 | `ios_app_bundle_id_prefix` and usually corresponds to a reversed domain name |
| 208 | (the default value is `"org.chromium"`). |
| 209 | |
| 210 | You then need to request provisioning profiles from Apple for your devices |
| 211 | for the following bundle identifiers to build and run Chromium with these |
| 212 | application extensions: |
| 213 | |
Javier Ernesto Flores Robles | e68ab7e5 | 2021-01-20 18:14:34 | [diff] [blame] | 214 | - `${prefix}.chrome.ios.dev` |
| 215 | - `${prefix}.chrome.ios.dev.ContentTodayExtension` |
| 216 | - `${prefix}.chrome.ios.dev.CredentialProviderExtension` |
Sylvain Defresne | c211708 | 2021-10-29 10:05:48 | [diff] [blame] | 217 | - `${prefix}.chrome.ios.dev.IntentsExtension` |
Henrique Ferreiro | dbd0865 | 2023-11-09 10:24:54 | [diff] [blame] | 218 | - `${prefix}.chrome.ios.dev.OpenExtension` |
Javier Ernesto Flores Robles | e68ab7e5 | 2021-01-20 18:14:34 | [diff] [blame] | 219 | - `${prefix}.chrome.ios.dev.ShareExtension` |
| 220 | - `${prefix}.chrome.ios.dev.TodayExtension` |
| 221 | - `${prefix}.chrome.ios.dev.WidgetKitExtension` |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 222 | |
| 223 | All these certificates need to have the "App Groups" |
| 224 | (`com.apple.security.application-groups`) capability enabled for |
| 225 | the following groups: |
| 226 | |
| 227 | - `group.${prefix}.chrome` |
| 228 | - `group.${prefix}.common` |
| 229 | |
| 230 | The `group.${prefix}.chrome` is only shared by Chromium and its extensions |
| 231 | to share files and configurations while the `group.${prefix}.common` is shared |
| 232 | with Chromium and other applications from the same organisation and can be used |
| 233 | to send commands to Chromium. |
| 234 | |
Henrique Ferreiro | 4607b3c | 2024-01-12 22:55:14 | [diff] [blame] | 235 | `${prefix}.chrome.ios.dev` and |
| 236 | `${prefix}.chrome.ios.dev.CredentialProviderExtension` need the AutoFill |
Takuto Ikuta | d36eb35 | 2022-03-01 01:39:48 | [diff] [blame] | 237 | Credential Provider Entitlement, which corresponds to the key |
Henrique Ferreiro | c1952db | 2024-03-27 23:50:03 | [diff] [blame] | 238 | `com.apple.developer.authentication-services.autofill-credential-provider`. |
| 239 | |
| 240 | `${prefix}.chrome.ios.dev` additionally needs the |
| 241 | `com.apple.developer.kernel.extended-virtual-addressing` entitlement when |
| 242 | running on a real device. |
Javier Ernesto Flores Robles | e68ab7e5 | 2021-01-20 18:14:34 | [diff] [blame] | 243 | |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 244 | ### Mobile provisioning profiles for tests |
| 245 | |
Justin Cohen | a819c11 | 2019-08-17 02:19:19 | [diff] [blame] | 246 | In addition to that, you need a different provisioning profile for each |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 247 | test application. Those provisioning profile will have a bundle identifier |
| 248 | matching the following pattern `${prefix}.gtest.${test-suite-name}` where |
| 249 | `${test-suite-name}` is the name of the test suite with underscores changed |
Tiago Vignatti | cdb9de4 | 2023-06-28 16:15:54 | [diff] [blame] | 250 | to dashes (e.g. `base_unittests` app will use `${prefix}.gtest.base-unittests` |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 251 | as bundle identifier). |
| 252 | |
| 253 | To be able to run the EarlGrey tests on a device, you'll need two provisioning |
| 254 | profiles for EarlGrey and OCHamcrest frameworks: |
| 255 | |
| 256 | - `${prefix}.test.OCHamcrest` |
| 257 | - `${prefix}.test.EarlGrey` |
| 258 | |
| 259 | In addition to that, then you'll need one additional provisioning profile for |
Justin Cohen | a819c11 | 2019-08-17 02:19:19 | [diff] [blame] | 260 | the XCTest module too. It must match the pattern: |
| 261 | `${prefix}.gtest.${test-suite-name}-module`. |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 262 | |
| 263 | ### Other applications |
| 264 | |
| 265 | Other applications like `ios_web_shell` usually will require mobile provisioning |
| 266 | profiles with bundle identifiers that may usually match the following pattern |
| 267 | `${prefix}.${application-name}` and may require specific capabilities. |
| 268 | |
| 269 | Generally, if the mobile provisioning profile is missing then the code signing |
| 270 | step will fail and will print the bundle identifier of the bundle that could not |
| 271 | be signed on the command line, e.g.: |
| 272 | |
| 273 | ```shell |
Dirk Pranke | 8bd55f2 | 2018-10-24 21:22:10 | [diff] [blame] | 274 | $ autoninja -C out/Debug-iphoneos ios_web_shell |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 275 | ninja: Entering directory `out/Debug-iphoneos' |
| 276 | FAILED: ios_web_shell.app/ios_web_shell ios_web_shell.app/_CodeSignature/CodeResources ios_web_shell.app/embedded.mobileprovision |
Rohit Rao | bc93a31b | 2024-08-12 14:28:08 | [diff] [blame] | 277 | python ../../build/config/apple/codesign.py code-sign-bundle -t=iphoneos -i=0123456789ABCDEF0123456789ABCDEF01234567 -e=../../build/config/ios/entitlements.plist -b=obj/ios/web/shell/ios_web_shell ios_web_shell.app |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 278 | Error: no mobile provisioning profile found for "org.chromium.ios-web-shell". |
| 279 | ninja: build stopped: subcommand failed. |
| 280 | ``` |
| 281 | |
| 282 | Here, the build is failing because there are no mobile provisioning profiles |
| 283 | installed that could sign the `ios_web_shell.app` bundle with the identity |
| 284 | `0123456789ABCDEF0123456789ABCDEF01234567`. To fix the build, you'll need to |
| 285 | request such a mobile provisioning profile from Apple. |
| 286 | |
| 287 | You can inspect the file passed via the `-e` flag to the `codesign.py` script |
Quinten Yearsley | 317532d | 2021-10-20 17:10:31 | [diff] [blame] | 288 | to check which capabilities are required for the mobile provisioning profile |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 289 | (e.g. `src/build/config/ios/entitlements.plist` for the above build error, |
| 290 | remember that the paths are relative to the build directory, not to the source |
| 291 | directory). |
| 292 | |
| 293 | If the required capabilities are not enabled on the mobile provisioning profile, |
| 294 | then it will be impossible to install the application on a device (Xcode will |
| 295 | display an error stating that "The application was signed with invalid |
| 296 | entitlements"). |
| 297 | |
Dave Tapuska | feb0745b | 2023-02-07 21:47:47 | [diff] [blame] | 298 | ## Building Blink for iOS |
| 299 | |
| 300 | The iOS build supports compiling the blink web platform. To compile blink |
| 301 | set a gn arg in your `.setup-gn` file. Note the blink web platform is |
Dave Tapuska | 176e8f9f | 2025-03-24 15:01:42 | [diff] [blame] | 302 | experimental code and should only be used for analysis. |
Dave Tapuska | feb0745b | 2023-02-07 21:47:47 | [diff] [blame] | 303 | |
| 304 | ``` |
| 305 | [gn_args] |
| 306 | use_blink = true |
Dave Tapuska | d5287f33 | 2025-03-04 16:32:55 | [diff] [blame] | 307 | ios_content_shell_bundle_identifier="REPLACE_YOUR_BUNDLE_IDENTIFIER_HERE" |
Dave Tapuska | feb0745b | 2023-02-07 21:47:47 | [diff] [blame] | 308 | ``` |
| 309 | Note that only certain targets support blink. `content_shell` being the |
| 310 | most useful. |
| 311 | |
| 312 | ```shell |
| 313 | $ autoninja -C out/Debug-iphonesimulator content_shell |
| 314 | ``` |
| 315 | |
Mark Cogan | 0abda965 | 2020-04-15 11:22:07 | [diff] [blame] | 316 | ## Running apps from the command line |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 317 | |
| 318 | Any target that is built and runs on the bots (see [below](#Troubleshooting)) |
| 319 | should run successfully in a local build. To run in the simulator from the |
| 320 | command line, you can use `iossim`. For example, to run a debug build of |
| 321 | `Chromium`: |
| 322 | |
| 323 | ```shell |
Tiago Vignatti | 9d51edea | 2024-01-13 00:11:49 | [diff] [blame] | 324 | $ out/Debug-iphonesimulator/iossim -i out/Debug-iphonesimulator/Chromium.app |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 325 | ``` |
| 326 | |
Raphael Kubo da Costa | 7702a7b | 2025-05-20 09:55:01 | [diff] [blame] | 327 | Note that `iossim` does not automatically launch the Simulator. This must be |
| 328 | done manually *after* running `iossim`. |
Mike Pinkerton | 90553fe | 2017-12-13 16:40:30 | [diff] [blame] | 329 | |
Vaclav Brozek | 09fe5ec | 2017-07-18 11:13:16 | [diff] [blame] | 330 | ### Passing arguments |
| 331 | |
| 332 | Arguments needed to be passed to the test application through `iossim`, such as |
| 333 | `--gtest_filter=SomeTest.FooBar` should be passed through the `-c` flag: |
| 334 | |
| 335 | ```shell |
Tiago Vignatti | 9d51edea | 2024-01-13 00:11:49 | [diff] [blame] | 336 | $ out/Debug-iphonesimulator/iossim -i \ |
Vaclav Brozek | 09fe5ec | 2017-07-18 11:13:16 | [diff] [blame] | 337 | -c "--gtest_filter=SomeTest.FooBar --gtest_repeat=3" \ |
| 338 | out/Debug-iphonesimulator/base_unittests.app |
| 339 | ``` |
| 340 | |
Mike Baxley | cb99a9f | 2017-07-12 15:16:11 | [diff] [blame] | 341 | ### Running EarlGrey tests |
| 342 | |
| 343 | EarlGrey tests are run differently than other test targets, as there is an |
| 344 | XCTest bundle that is injected into the target application. Therefore you must |
| 345 | also pass in the test bundle: |
| 346 | |
| 347 | ```shell |
Tiago Vignatti | 9d51edea | 2024-01-13 00:11:49 | [diff] [blame] | 348 | $ out/Debug-iphonesimulator/iossim -i \ |
Mike Baxley | cb99a9f | 2017-07-12 15:16:11 | [diff] [blame] | 349 | out/Debug-iphonesimulator/ios_chrome_ui_egtests.app \ |
| 350 | out/Debug-iphonesimulator/ios_chrome_ui_egtests.app/PlugIns/ios_chrome_ui_egtests_module.xctest |
| 351 | ``` |
| 352 | |
Gyuyoung Kim | 9497f0eb | 2023-09-19 05:32:04 | [diff] [blame] | 353 | ### Running Web Tests on Blink for iOS |
| 354 | |
| 355 | The current Blink for iOS only supports running Web Tests on the simulator |
| 356 | environment now. Before you run the web tests, you need to build the blink_tests |
| 357 | target to get content_shell and all of the other needed binaries for the |
| 358 | simulator test environment. |
| 359 | |
| 360 | ```shell |
| 361 | $ autoninja -C out/Debug-iphonesimulator blink_tests |
| 362 | ``` |
| 363 | |
| 364 | When the blink_tests target is complete you can then run the test runner script |
| 365 | (third_party/blink/tools/run_web_tests.py) as below. See [Web Tests](https://chromium.googlesource.com/chromium/src/+/HEAD/docs/testing/web_tests.md) document |
| 366 | for more information. |
| 367 | |
| 368 | ```shell |
| 369 | $ third_party/blink/tools/run_web_tests.py -t Debug-iphonesimulator \ |
| 370 | --platform ios |
| 371 | ``` |
| 372 | |
Sylvain Defresne | d019a70 | 2018-02-01 10:11:51 | [diff] [blame] | 373 | ### Running on specific simulator |
| 374 | |
| 375 | By default, `iossim` will pick an arbitrary simulator to run the tests. If |
| 376 | you want to run them on a specific simulator, you can use `-d` to pick the |
| 377 | simulated device and `-s` to select the iOS version. |
| 378 | |
| 379 | For example, to run the tests on a simulated iPhone 6s running iOS 10.0, |
| 380 | you would invoke `iossim` like this. |
| 381 | |
| 382 | ```shell |
Tiago Vignatti | 9d51edea | 2024-01-13 00:11:49 | [diff] [blame] | 383 | $ out/Debug-iphonesimulator/iossim -i -d 'iPhone 6s' -s '10.0' \ |
Sylvain Defresne | d019a70 | 2018-02-01 10:11:51 | [diff] [blame] | 384 | out/Debug-iphonesimulator/base_unittests.app |
| 385 | ``` |
| 386 | |
| 387 | Please note that by default only a subset of simulator devices are installed |
| 388 | with Xcode. You may have to install additional simulators in Xcode (or even |
| 389 | an older version of Xcode) to be able to run on a specific configuration. |
| 390 | |
| 391 | Go to "Preferences > Components" tab in Xcode to install other simulator images |
| 392 | (this is the location the setting is in Xcode 9.2; it may be different in other |
| 393 | version of the tool). |
| 394 | |
Tiago Vignatti | e1599c5 | 2023-04-21 07:14:46 | [diff] [blame] | 395 | ### Remote debugging with DevTools (on Blink for iOS) |
| 396 | |
| 397 | Developers are able to remotely use DevTools in a host machine (e.g. Mac) and |
| 398 | inspect `content_shell` for development. |
| 399 | |
| 400 | On the simulator, one just needs to pass the `--remote-debugging-port=9222` |
| 401 | argument for `content_shell` and in the host machine access it via |
| 402 | `chrome://inspect`. It is possible to change the default port listening (9222) |
| 403 | and configure another one via the "Configure…" button and then "Target |
| 404 | discovery settings" dialog. |
| 405 | |
| 406 | To use DevTools in the remote device it is necessary to also pass the remote |
| 407 | debugging address argument to `content-shell` so any address could bind for |
| 408 | debugging: ` --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222`. |
| 409 | Then in the host machine one needs to configure the IP address of the device in |
| 410 | the "Target discovery settings" dialog e.g. `192.168.0.102:9222`. |
| 411 | |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 412 | ## Update your checkout |
| 413 | |
| 414 | To update an existing checkout, you can run |
| 415 | |
| 416 | ```shell |
| 417 | $ git rebase-update |
| 418 | $ gclient sync |
| 419 | ``` |
| 420 | |
| 421 | The first command updates the primary Chromium source repository and rebases |
| 422 | any of your local branches on top of tip-of-tree (aka the Git branch |
Andrew Williams | bbc1a1e | 2021-07-21 01:51:22 | [diff] [blame] | 423 | `origin/main`). If you don't want to use this script, you can also just use |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 424 | `git pull` or other common Git commands to update the repo. |
| 425 | |
| 426 | The second command syncs dependencies to the appropriate versions and re-runs |
| 427 | hooks as needed. |
| 428 | |
| 429 | ## Tips, tricks, and troubleshooting |
| 430 | |
Mark Cogan | 0abda965 | 2020-04-15 11:22:07 | [diff] [blame] | 431 | Remember that the XCode project you interact with while working on Chromium is a |
| 432 | build artifact, generated from the `BUILD.gn` files. Do not use it to add new |
| 433 | files; instead see the procedures for [working with |
| 434 | files](working_with_files.md). |
| 435 | |
Raphael Kubo da Costa | 7702a7b | 2025-05-20 09:55:01 | [diff] [blame] | 436 | If you have problems building, you can join us on |
| 437 | [Slack](https://www.chromium.org/developers/slack/) or one of our [mailing |
| 438 | lists](https://www.chromium.org/developers/technical-discussion-groups/). |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 439 | |
Sylvain Defresne | 01e2ded | 2020-12-02 11:18:30 | [diff] [blame] | 440 | ### Debugging |
| 441 | |
Takuto Ikuta | 7478af72 | 2024-05-27 07:23:19 | [diff] [blame] | 442 | To help with deterministic builds, and to work with reclient, the path to source |
Sylvain Defresne | 01e2ded | 2020-12-02 11:18:30 | [diff] [blame] | 443 | files in debugging symbols are relative to source directory. To allow Xcode |
| 444 | to find the source files, you need to ensure to have an `~/.lldbinit-Xcode` |
| 445 | file with the following lines into it (substitute {SRC} for your actual path |
| 446 | to the root of Chromium's sources): |
| 447 | |
| 448 | ``` |
| 449 | script sys.path[:0] = ['{SRC}/tools/lldb'] |
| 450 | script import lldbinit |
| 451 | ``` |
| 452 | |
| 453 | This will also allow you to see the content of some of Chromium types in the |
Jan Wilken Dörrie | 85285b0 | 2021-03-11 23:38:47 | [diff] [blame] | 454 | debugger like `std::u16string`, ... If you want to use `lldb` directly, name |
Sylvain Defresne | 01e2ded | 2020-12-02 11:18:30 | [diff] [blame] | 455 | the file `~/.lldbinit` instead of `~/.lldbinit-Xcode`. |
| 456 | |
Sylvain Defresne | 1d01bff0 | 2021-01-29 01:13:10 | [diff] [blame] | 457 | Note: if you are using `ios/build/tools/setup-gn.py` to generate the Xcode |
| 458 | project, the script also generate an `.lldbinit` file next to the project and |
| 459 | configure Xcode to use that file instead of the global one. |
| 460 | |
Sylvain Defresne | 7080fe3b | 2020-11-16 15:57:51 | [diff] [blame] | 461 | ### Changing the version of Xcode |
| 462 | |
| 463 | To change the version of Xcode used to build Chromium on iOS, please follow |
| 464 | the steps below: |
| 465 | |
| 466 | 1. Launch the new version of Xcode.app. |
| 467 | |
| 468 | This is required as Xcode may need to install some components into |
| 469 | the system before the new version can be used from the command-line. |
| 470 | |
| 471 | 1. Reboot your computer. |
| 472 | |
| 473 | This is required as some of Xcode components are daemons that are not |
| 474 | automatically stopped when updating Xcode, and command-line tools will |
| 475 | fail if the daemon version is incompatible (usually `actool` fails). |
| 476 | |
| 477 | 1. Run `gn gen`. |
| 478 | |
| 479 | This is required as the `ninja` files generated by `gn` encodes some |
| 480 | information about Xcode (notably the path to the SDK, ...) that will |
| 481 | change with each version. It is not possible to have `ninja` re-run |
| 482 | `gn gen` automatically when those changes unfortunately. |
| 483 | |
| 484 | If you have a downstream chekout, run `gclient runhooks` instead of |
| 485 | `gn gen` as it will ensure that `gn gen` will be run automatically |
| 486 | for all possible combination of target and configuration from within |
| 487 | Xcode. |
| 488 | |
| 489 | If you skip some of those steps, the build may occasionally succeed, but |
| 490 | it has been observed in the past that those steps are required in the |
| 491 | vast majority of the situation. Please save yourself some painful build |
| 492 | debugging and follow them. |
| 493 | |
| 494 | If you use `xcode-select` to switch between multiple version of Xcode, |
| 495 | you will have to follow the same steps. |
| 496 | |
Bruce Dawson | 425d4ab | 2023-06-25 01:36:15 | [diff] [blame] | 497 | ### Improving performance of git commands |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 498 | |
isherman | ce1d9d8 | 2017-05-12 23:10:04 | [diff] [blame] | 499 | #### Increase the vnode cache size |
| 500 | |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 501 | `git status` is used frequently to determine the status of your checkout. Due |
| 502 | to the large number of files in Chromium's checkout, `git status` performance |
| 503 | can be quite variable. Increasing the system's vnode cache appears to help. |
| 504 | By default, this command: |
| 505 | |
| 506 | ```shell |
| 507 | $ sysctl -a | egrep kern\..*vnodes |
| 508 | ``` |
| 509 | |
| 510 | Outputs `kern.maxvnodes: 263168` (263168 is 257 * 1024). To increase this |
| 511 | setting: |
| 512 | |
| 513 | ```shell |
| 514 | $ sudo sysctl kern.maxvnodes=$((512*1024)) |
| 515 | ``` |
| 516 | |
| 517 | Higher values may be appropriate if you routinely move between different |
| 518 | Chromium checkouts. This setting will reset on reboot, the startup setting can |
| 519 | be set in `/etc/sysctl.conf`: |
| 520 | |
| 521 | ```shell |
| 522 | $ echo kern.maxvnodes=$((512*1024)) | sudo tee -a /etc/sysctl.conf |
| 523 | ``` |
| 524 | |
| 525 | Or edit the file directly. |
| 526 | |
isherman | ce1d9d8 | 2017-05-12 23:10:04 | [diff] [blame] | 527 | #### Configure git to use an untracked cache |
| 528 | |
Bruce Dawson | 2154274a | 2023-06-17 22:24:29 | [diff] [blame] | 529 | Try running |
isherman | ce1d9d8 | 2017-05-12 23:10:04 | [diff] [blame] | 530 | |
| 531 | ```shell |
| 532 | $ git update-index --test-untracked-cache |
| 533 | ``` |
| 534 | |
| 535 | If the output ends with `OK`, then the following may also improve performance of |
| 536 | `git status`: |
| 537 | |
| 538 | ```shell |
| 539 | $ git config core.untrackedCache true |
| 540 | ``` |
| 541 | |
Tiago Vignatti | 760b0c0 | 2023-05-29 19:45:24 | [diff] [blame] | 542 | #### Configure git to use fsmonitor |
| 543 | |
Bruce Dawson | 2154274a | 2023-06-17 22:24:29 | [diff] [blame] | 544 | You can significantly speed up git by using [fsmonitor.](https://github.blog/2022-06-29-improve-git-monorepo-performance-with-a-file-system-monitor/) |
| 545 | You should enable fsmonitor in large repos, such as Chromium and v8. Enabling |
Avi Drissman | 9908ae44 | 2023-09-29 16:31:11 | [diff] [blame] | 546 | it globally will launch many processes and probably isn't worthwhile. Be sure |
| 547 | you have at least version 2.43 (fsmonitor on the Mac is broken before then). The |
Bruce Dawson | 2154274a | 2023-06-17 22:24:29 | [diff] [blame] | 548 | command to enable fsmonitor in the current repo is: |
Tiago Vignatti | 760b0c0 | 2023-05-29 19:45:24 | [diff] [blame] | 549 | |
| 550 | ```shell |
| 551 | $ git config core.fsmonitor true |
| 552 | ``` |
| 553 | |
michaeldo | 8cccf214 | 2017-03-06 22:12:02 | [diff] [blame] | 554 | ### Xcode license agreement |
| 555 | |
| 556 | If you're getting the error |
| 557 | |
| 558 | > Agreeing to the Xcode/iOS license requires admin privileges, please re-run as |
| 559 | > root via sudo. |
| 560 | |
| 561 | the Xcode license hasn't been accepted yet which (contrary to the message) any |
| 562 | user can do by running: |
| 563 | |
| 564 | ```shell |
| 565 | $ xcodebuild -license |
| 566 | ``` |
| 567 | |
| 568 | Only accepting for all users of the machine requires root: |
| 569 | |
| 570 | ```shell |
| 571 | $ sudo xcodebuild -license |
| 572 | ``` |