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