blob: 37afefccff6adc16bf239ea6c5ec730bfcda6274 [file] [log] [blame] [view]
michaeldo8cccf2142017-03-06 22:12:021# Checking out and building Chromium for iOS
2
3There are instructions for other platforms linked from the
4[get the code](../get_the_code.md) page.
5
6## Instructions for Google Employees
7
8Are 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 Defresne09a1b992025-01-08 15:02:3915<!-- LINT.IfChange -->
Sylvain Defresne1a98f762025-01-07 14:08:5016
Sylvain Defresne991d8e22023-11-29 17:15:3017* A 64-bit Mac capable of running the required version of Xcode.
Justin Cohen9a1c7772024-10-01 21:37:4118* [Xcode](https://developer.apple.com/xcode) 16.0 or higher.
Sylvain Defresne991d8e22023-11-29 17:15:3019
Sylvain Defresne09a1b992025-01-08 15:02:3920<!-- LINT.ThenChange(//ios/build/chrome_build.gni) -->
21
Sylvain Defresne991d8e22023-11-29 17:15:3022Note: after installing Xcode, you need to launch it and to let it install
23the iOS simulator. This is required as part of the build, see [this discussion](
24https://groups.google.com/a/chromium.org/g/chromium-dev/c/98d6MyLoYHM/m/A_HyOGxPAgAJ)
25on chromium-dev.
michaeldo8cccf2142017-03-06 22:12:0226
27## Install `depot_tools`
28
29Clone the `depot_tools` repository:
30
31```shell
32$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
33```
34
Sylvain Defresne2522b842025-03-11 19:10:2435You 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
37add the `depot_tools/python-bin` directory to your `PATH` to get access to
38a recent version of python3 (the version shipped by default on macOS tends
39to be quite old which can lead to build failure).
40
41To do that, edit your shell login script (e.g. `~/.bash_profile`, `~/.zprofile`)
42and add the following line at the end (assuming you've checked out `depot_tools`
43in your `HOME` directory):
michaeldo8cccf2142017-03-06 22:12:0244
45```shell
Sylvain Defresne2522b842025-03-11 19:10:2446export PATH="$HOME/depot_tools:$HOME/depot_tools/python-bin:$PATH"
michaeldo8cccf2142017-03-06 22:12:0247```
48
Sylvain Defresne2522b842025-03-11 19:10:2449You may need to run `gclient status` to force an update of `depot_tools`
50before the `python3` command work once you've updated your `PATH`.
51
52You can omit `$HOME/depot_tools/python-bin` if you already have a recent
53version of python installed and you manually manage it (but this may lead
54to unexpected build failures).
55
michaeldo8cccf2142017-03-06 22:12:0256## Get the code
57
58Create a `chromium` directory for the checkout and change to it (you can call
59this whatever you like and put it wherever you like, as
60long as the full path has no spaces):
61
62```shell
63$ mkdir chromium && cd chromium
64```
65
66Run the `fetch` tool from `depot_tools` to check out the code and its
67dependencies.
68
69```shell
70$ fetch ios
71```
72
73If you don't want the full repo history, you can save a lot of time by
74adding the `--no-history` flag to `fetch`.
75
76Expect the command to take 30 minutes on even a fast connection, and many
77hours on slower ones.
78
79When `fetch` completes, it will have created a hidden `.gclient` file and a
80directory called `src` in the working directory. The remaining instructions
81assume you have switched to the `src` directory:
82
83```shell
84$ cd src
85```
86
87*Optional*: You can also [install API
88keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your
89build to talk to some Google services, but this is not necessary for most
90development and testing purposes.
91
92## Setting up the build
93
94Since 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
96build directories under `out` for Release and Debug device and simulator
Sylvain Defresnefc11bcd2020-06-26 13:42:0097builds, and generates an appropriate Xcode project (`out/build/all.xcodeproj`)
98as well.
michaeldo8cccf2142017-03-06 22:12:0299
Sylvain Defresnefc11bcd2020-06-26 13:42:00100More information about [developing with Xcode](xcode_tips.md). *Xcode project
101is an artifact, any changes made in the project itself will be ignored.*
Mike Doughertyd8947a592020-05-07 19:43:46102
Raphael Kubo da costa47cb1072024-12-11 18:37:29103You can customize the build by editing a file called `.setup-gn` (create it if
104it 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
110Look at `src/ios/build/tools/setup-gn.config` for available configuration
111options.
michaeldo8cccf2142017-03-06 22:12:02112
113From this point, you can either build from Xcode or from the command line using
Dirk Pranke8bd55f22018-10-24 21:22:10114`autoninja`. `setup-gn.py` creates sub-directories named
michaeldo8cccf2142017-03-06 22:12:02115`out/${configuration}-${platform}`, so for a `Debug` build for simulator use:
116
117```shell
Dirk Pranke8bd55f22018-10-24 21:22:10118$ autoninja -C out/Debug-iphonesimulator gn_all
michaeldo8cccf2142017-03-06 22:12:02119```
120
Dirk Pranke8bd55f22018-10-24 21:22:10121(`autoninja` is a wrapper that automatically provides optimal values for the
122arguments passed to `ninja`.)
123
Mike Doughertyd8947a592020-05-07 19:43:46124Note: The `setup-gn.py` script needs to run every time one of the `BUILD.gn`
125files is updated (either by you or after rebasing). If you forget to run it,
126the list of targets and files in the Xcode solution may be stale. You can run
127the script directly or use either `gclient sync` or `gclient runhooks` which
128will run `setup-gn.py` for you as part of the update hooks.
michaeldo8cccf2142017-03-06 22:12:02129
Sylvain Defresne9932328e2020-07-09 10:44:40130You can add a custom hook to `.gclient` file to configure `setup-gn.py` to
131be run as part of `gclient runhooks`. In that case, your `.gclient` file
132would look like this:
133
134```
135solutions = [
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 Ikutad36eb352022-03-01 01:39:48147 "python3",
Sylvain Defresne9932328e2020-07-09 10:44:40148 "src/ios/build/tools/setup-gn.py",
149 ]
150 }],
151 "safesync_url": "",
152 },
153]
154target_os = ["ios"]
155target_os_only = True
156```
157
michaeldo8cccf2142017-03-06 22:12:02158You can also follow the manual instructions on the
159[Mac page](../mac_build_instructions.md), but make sure you set the
160GN arg `target_os="ios"`.
161
Andrew Williams54da9cc2024-01-09 17:32:23162### Faster builds
163
164This section contains some things you can change to speed up your builds,
165sorted so that the things that make the biggest difference are first.
166
167#### Use Reclient
168
169Google employees should use Reclient, a distributed compilation system. Detailed
170information is available internally but the relevant gn arg is:
171* `use_remoteexec = true`
172
173Google employees can visit
174[go/building-chrome-mac#using-remote-execution](https://goto.google.com/building-chrome-mac#using-remote-execution)
175for more information. For external contributors, Reclient does not support iOS
176builds.
177
michaeldo8cccf2142017-03-06 22:12:02178## Building for device
179
180To be able to build and run Chromium and the tests for devices, you need to
181have an Apple developer account (a free one will work) and the appropriate
182provisioning profiles, then configure the build to use them.
183
184### Code signing identity
185
186Please refer to the Apple documentation on how to get a code signing identity
187and certificates. You can check that you have a code signing identity correctly
188installed 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
196If the command output says you have zero valid identities, then you do not
197have a code signing identity installed and need to get one from Apple. If
198you have more than one identity, the build system may select the wrong one
199automatically, and you can use the `ios_code_signing_identity` gn variable
200to control which one to use by setting it to the identity hash, e.g. to
201`"0123456789ABCDEF0123456789ABCDEF01234567"`.
202
203### Mobile provisioning profiles
204
205Once you have the code signing identity, you need to decide on a prefix
206for 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
210You then need to request provisioning profiles from Apple for your devices
211for the following bundle identifiers to build and run Chromium with these
212application extensions:
213
Javier Ernesto Flores Roblese68ab7e52021-01-20 18:14:34214- `${prefix}.chrome.ios.dev`
215- `${prefix}.chrome.ios.dev.ContentTodayExtension`
216- `${prefix}.chrome.ios.dev.CredentialProviderExtension`
Sylvain Defresnec2117082021-10-29 10:05:48217- `${prefix}.chrome.ios.dev.IntentsExtension`
Henrique Ferreirodbd08652023-11-09 10:24:54218- `${prefix}.chrome.ios.dev.OpenExtension`
Javier Ernesto Flores Roblese68ab7e52021-01-20 18:14:34219- `${prefix}.chrome.ios.dev.ShareExtension`
220- `${prefix}.chrome.ios.dev.TodayExtension`
221- `${prefix}.chrome.ios.dev.WidgetKitExtension`
michaeldo8cccf2142017-03-06 22:12:02222
223All these certificates need to have the "App Groups"
224(`com.apple.security.application-groups`) capability enabled for
225the following groups:
226
227- `group.${prefix}.chrome`
228- `group.${prefix}.common`
229
230The `group.${prefix}.chrome` is only shared by Chromium and its extensions
231to share files and configurations while the `group.${prefix}.common` is shared
232with Chromium and other applications from the same organisation and can be used
233to send commands to Chromium.
234
Henrique Ferreiro4607b3c2024-01-12 22:55:14235`${prefix}.chrome.ios.dev` and
236`${prefix}.chrome.ios.dev.CredentialProviderExtension` need the AutoFill
Takuto Ikutad36eb352022-03-01 01:39:48237Credential Provider Entitlement, which corresponds to the key
Henrique Ferreiroc1952db2024-03-27 23:50:03238`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
242running on a real device.
Javier Ernesto Flores Roblese68ab7e52021-01-20 18:14:34243
michaeldo8cccf2142017-03-06 22:12:02244### Mobile provisioning profiles for tests
245
Justin Cohena819c112019-08-17 02:19:19246In addition to that, you need a different provisioning profile for each
michaeldo8cccf2142017-03-06 22:12:02247test application. Those provisioning profile will have a bundle identifier
248matching the following pattern `${prefix}.gtest.${test-suite-name}` where
249`${test-suite-name}` is the name of the test suite with underscores changed
Tiago Vignatticdb9de42023-06-28 16:15:54250to dashes (e.g. `base_unittests` app will use `${prefix}.gtest.base-unittests`
michaeldo8cccf2142017-03-06 22:12:02251as bundle identifier).
252
253To be able to run the EarlGrey tests on a device, you'll need two provisioning
254profiles for EarlGrey and OCHamcrest frameworks:
255
256- `${prefix}.test.OCHamcrest`
257- `${prefix}.test.EarlGrey`
258
259In addition to that, then you'll need one additional provisioning profile for
Justin Cohena819c112019-08-17 02:19:19260the XCTest module too. It must match the pattern:
261`${prefix}.gtest.${test-suite-name}-module`.
michaeldo8cccf2142017-03-06 22:12:02262
263### Other applications
264
265Other applications like `ios_web_shell` usually will require mobile provisioning
266profiles with bundle identifiers that may usually match the following pattern
267`${prefix}.${application-name}` and may require specific capabilities.
268
269Generally, if the mobile provisioning profile is missing then the code signing
270step will fail and will print the bundle identifier of the bundle that could not
271be signed on the command line, e.g.:
272
273```shell
Dirk Pranke8bd55f22018-10-24 21:22:10274$ autoninja -C out/Debug-iphoneos ios_web_shell
michaeldo8cccf2142017-03-06 22:12:02275ninja: Entering directory `out/Debug-iphoneos'
276FAILED: ios_web_shell.app/ios_web_shell ios_web_shell.app/_CodeSignature/CodeResources ios_web_shell.app/embedded.mobileprovision
Rohit Raobc93a31b2024-08-12 14:28:08277python ../../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
michaeldo8cccf2142017-03-06 22:12:02278Error: no mobile provisioning profile found for "org.chromium.ios-web-shell".
279ninja: build stopped: subcommand failed.
280```
281
282Here, the build is failing because there are no mobile provisioning profiles
283installed that could sign the `ios_web_shell.app` bundle with the identity
284`0123456789ABCDEF0123456789ABCDEF01234567`. To fix the build, you'll need to
285request such a mobile provisioning profile from Apple.
286
287You can inspect the file passed via the `-e` flag to the `codesign.py` script
Quinten Yearsley317532d2021-10-20 17:10:31288to check which capabilities are required for the mobile provisioning profile
michaeldo8cccf2142017-03-06 22:12:02289(e.g. `src/build/config/ios/entitlements.plist` for the above build error,
290remember that the paths are relative to the build directory, not to the source
291directory).
292
293If the required capabilities are not enabled on the mobile provisioning profile,
294then it will be impossible to install the application on a device (Xcode will
295display an error stating that "The application was signed with invalid
296entitlements").
297
Dave Tapuskafeb0745b2023-02-07 21:47:47298## Building Blink for iOS
299
300The iOS build supports compiling the blink web platform. To compile blink
301set a gn arg in your `.setup-gn` file. Note the blink web platform is
Dave Tapuska176e8f9f2025-03-24 15:01:42302experimental code and should only be used for analysis.
Dave Tapuskafeb0745b2023-02-07 21:47:47303
304```
305[gn_args]
306use_blink = true
Dave Tapuskad5287f332025-03-04 16:32:55307ios_content_shell_bundle_identifier="REPLACE_YOUR_BUNDLE_IDENTIFIER_HERE"
Victor Hugo Vianna Silva1389d0fa2025-05-29 16:45:20308ios_chromium_bundle_id="REPLACE_YOUR_BUNDLE_IDENTIFIER_HERE"
Dave Tapuskafeb0745b2023-02-07 21:47:47309```
Victor Hugo Vianna Silva1389d0fa2025-05-29 16:45:20310Note that only certain targets support blink. `content_shell` and `chrome`
311being the most useful.
Dave Tapuskafeb0745b2023-02-07 21:47:47312
313```shell
Victor Hugo Vianna Silva1389d0fa2025-05-29 16:45:20314$ autoninja -C out/Debug-iphonesimulator content_shell chrome
Dave Tapuskafeb0745b2023-02-07 21:47:47315```
316
Gyuyoung Kim03bcb2562025-05-22 21:38:45317## Blink for tvOS builds and running
318
Gyuyoung Kima8d4ea92025-05-26 23:31:12319Note: To build Blink for tvOS, make sure that the tvOS SDK and the tvOS
320simulator are installed on your system.
321
Gyuyoung Kim03bcb2562025-05-22 21:38:45322Blink for tvOS is an experimental project that aims to port Blink to Apple tvOS.
323Due to platform limitations, specifically because tvOS does not support
324multi-process applications, Blink for tvOS runs in a single-process mode only.
325As a result, there is no security isolation, since all content runs within the
326same process. Therefore, it is intended solely for loading trusted content.
327Please note that this project is still under development and considered
328unstable.
329
Gyuyoung Kima8d4ea92025-05-26 23:31:12330tvOS is an iOS-based platform, and within the Chromium project, it is treated as
331a variant of the iOS build. As such, the same setup instructions used for iOS
332also apply to tvOS.
333
Gyuyoung Kim03bcb2562025-05-22 21:38:45334If you use the `setup-gn.py` script as described above, it will automatically
335create `out/${configuration}-appletvsimulator` and
336`out/${configuration}-appletvos` directories with the appropriate GN arguments.
337
338If you would like to set your build up manually, the following GN arguments are
339required:
340
341```
342target_os="ios"
343target_platform="tvos"
344use_blink=true
345```
346
347Currently, tvOS supports only a limited set of targets, with `content_shell`
348being the most useful one. Note that `chrome` is not a supported target.
349
350The `iossim` tool also supports tvOS via the `-x tvos` argument. You can run a
351debug build of `content_shell`:
352
353```shell
354$ out/Debug-appletvsimulator/iossim -d 'Apple TV' -s '18.4' -x tvos \
355 out/Debug-appletvsimulator/content_shell.app
356```
357
Mark Cogan0abda9652020-04-15 11:22:07358## Running apps from the command line
michaeldo8cccf2142017-03-06 22:12:02359
360Any target that is built and runs on the bots (see [below](#Troubleshooting))
361should run successfully in a local build. To run in the simulator from the
362command line, you can use `iossim`. For example, to run a debug build of
363`Chromium`:
364
365```shell
Tiago Vignatti9d51edea2024-01-13 00:11:49366$ out/Debug-iphonesimulator/iossim -i out/Debug-iphonesimulator/Chromium.app
michaeldo8cccf2142017-03-06 22:12:02367```
368
Raphael Kubo da Costa7702a7b2025-05-20 09:55:01369Note that `iossim` does not automatically launch the Simulator. This must be
370done manually *after* running `iossim`.
Mike Pinkerton90553fe2017-12-13 16:40:30371
Vaclav Brozek09fe5ec2017-07-18 11:13:16372### Passing arguments
373
374Arguments needed to be passed to the test application through `iossim`, such as
375`--gtest_filter=SomeTest.FooBar` should be passed through the `-c` flag:
376
377```shell
Tiago Vignatti9d51edea2024-01-13 00:11:49378$ out/Debug-iphonesimulator/iossim -i \
Vaclav Brozek09fe5ec2017-07-18 11:13:16379 -c "--gtest_filter=SomeTest.FooBar --gtest_repeat=3" \
380 out/Debug-iphonesimulator/base_unittests.app
381```
382
Mike Baxleycb99a9f2017-07-12 15:16:11383### Running EarlGrey tests
384
385EarlGrey tests are run differently than other test targets, as there is an
386XCTest bundle that is injected into the target application. Therefore you must
387also pass in the test bundle:
388
389```shell
Tiago Vignatti9d51edea2024-01-13 00:11:49390$ out/Debug-iphonesimulator/iossim -i \
Mike Baxleycb99a9f2017-07-12 15:16:11391 out/Debug-iphonesimulator/ios_chrome_ui_egtests.app \
392 out/Debug-iphonesimulator/ios_chrome_ui_egtests.app/PlugIns/ios_chrome_ui_egtests_module.xctest
393```
394
Gyuyoung Kim9497f0eb2023-09-19 05:32:04395### Running Web Tests on Blink for iOS
396
397The current Blink for iOS only supports running Web Tests on the simulator
398environment now. Before you run the web tests, you need to build the blink_tests
399target to get content_shell and all of the other needed binaries for the
400simulator test environment.
401
402```shell
403$ autoninja -C out/Debug-iphonesimulator blink_tests
404```
405
406When the blink_tests target is complete you can then run the test runner script
407(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
408for more information.
409
410```shell
411$ third_party/blink/tools/run_web_tests.py -t Debug-iphonesimulator \
412 --platform ios
413```
414
Sylvain Defresned019a702018-02-01 10:11:51415### Running on specific simulator
416
417By default, `iossim` will pick an arbitrary simulator to run the tests. If
418you want to run them on a specific simulator, you can use `-d` to pick the
419simulated device and `-s` to select the iOS version.
420
421For example, to run the tests on a simulated iPhone 6s running iOS 10.0,
422you would invoke `iossim` like this.
423
424```shell
Tiago Vignatti9d51edea2024-01-13 00:11:49425$ out/Debug-iphonesimulator/iossim -i -d 'iPhone 6s' -s '10.0' \
Sylvain Defresned019a702018-02-01 10:11:51426 out/Debug-iphonesimulator/base_unittests.app
427```
428
429Please note that by default only a subset of simulator devices are installed
430with Xcode. You may have to install additional simulators in Xcode (or even
431an older version of Xcode) to be able to run on a specific configuration.
432
433Go to "Preferences > Components" tab in Xcode to install other simulator images
434(this is the location the setting is in Xcode 9.2; it may be different in other
435version of the tool).
436
Tiago Vignattie1599c52023-04-21 07:14:46437### Remote debugging with DevTools (on Blink for iOS)
438
439Developers are able to remotely use DevTools in a host machine (e.g. Mac) and
440inspect `content_shell` for development.
441
442On the simulator, one just needs to pass the `--remote-debugging-port=9222`
443argument for `content_shell` and in the host machine access it via
444`chrome://inspect`. It is possible to change the default port listening (9222)
445and configure another one via the "Configure…" button and then "Target
446discovery settings" dialog.
447
448To use DevTools in the remote device it is necessary to also pass the remote
449debugging address argument to `content-shell` so any address could bind for
450debugging: ` --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222`.
451Then in the host machine one needs to configure the IP address of the device in
452the "Target discovery settings" dialog e.g. `192.168.0.102:9222`.
453
michaeldo8cccf2142017-03-06 22:12:02454## Update your checkout
455
456To update an existing checkout, you can run
457
458```shell
459$ git rebase-update
460$ gclient sync
461```
462
463The first command updates the primary Chromium source repository and rebases
464any of your local branches on top of tip-of-tree (aka the Git branch
Andrew Williamsbbc1a1e2021-07-21 01:51:22465`origin/main`). If you don't want to use this script, you can also just use
michaeldo8cccf2142017-03-06 22:12:02466`git pull` or other common Git commands to update the repo.
467
468The second command syncs dependencies to the appropriate versions and re-runs
469hooks as needed.
470
471## Tips, tricks, and troubleshooting
472
Mark Cogan0abda9652020-04-15 11:22:07473Remember that the XCode project you interact with while working on Chromium is a
474build artifact, generated from the `BUILD.gn` files. Do not use it to add new
475files; instead see the procedures for [working with
476files](working_with_files.md).
477
Raphael Kubo da Costa7702a7b2025-05-20 09:55:01478If you have problems building, you can join us on
479[Slack](https://www.chromium.org/developers/slack/) or one of our [mailing
480lists](https://www.chromium.org/developers/technical-discussion-groups/).
michaeldo8cccf2142017-03-06 22:12:02481
Sylvain Defresne01e2ded2020-12-02 11:18:30482### Debugging
483
Takuto Ikuta7478af722024-05-27 07:23:19484To help with deterministic builds, and to work with reclient, the path to source
Sylvain Defresne01e2ded2020-12-02 11:18:30485files in debugging symbols are relative to source directory. To allow Xcode
486to find the source files, you need to ensure to have an `~/.lldbinit-Xcode`
487file with the following lines into it (substitute {SRC} for your actual path
488to the root of Chromium's sources):
489
490```
491script sys.path[:0] = ['{SRC}/tools/lldb']
492script import lldbinit
493```
494
495This will also allow you to see the content of some of Chromium types in the
Jan Wilken Dörrie85285b02021-03-11 23:38:47496debugger like `std::u16string`, ... If you want to use `lldb` directly, name
Sylvain Defresne01e2ded2020-12-02 11:18:30497the file `~/.lldbinit` instead of `~/.lldbinit-Xcode`.
498
Sylvain Defresne1d01bff02021-01-29 01:13:10499Note: if you are using `ios/build/tools/setup-gn.py` to generate the Xcode
500project, the script also generate an `.lldbinit` file next to the project and
501configure Xcode to use that file instead of the global one.
502
Sylvain Defresne7080fe3b2020-11-16 15:57:51503### Changing the version of Xcode
504
505To change the version of Xcode used to build Chromium on iOS, please follow
506the steps below:
507
5081. Launch the new version of Xcode.app.
509
510 This is required as Xcode may need to install some components into
511 the system before the new version can be used from the command-line.
512
5131. Reboot your computer.
514
515 This is required as some of Xcode components are daemons that are not
516 automatically stopped when updating Xcode, and command-line tools will
517 fail if the daemon version is incompatible (usually `actool` fails).
518
5191. Run `gn gen`.
520
521 This is required as the `ninja` files generated by `gn` encodes some
522 information about Xcode (notably the path to the SDK, ...) that will
523 change with each version. It is not possible to have `ninja` re-run
524 `gn gen` automatically when those changes unfortunately.
525
526 If you have a downstream chekout, run `gclient runhooks` instead of
527 `gn gen` as it will ensure that `gn gen` will be run automatically
528 for all possible combination of target and configuration from within
529 Xcode.
530
531If you skip some of those steps, the build may occasionally succeed, but
532it has been observed in the past that those steps are required in the
533vast majority of the situation. Please save yourself some painful build
534debugging and follow them.
535
536If you use `xcode-select` to switch between multiple version of Xcode,
537you will have to follow the same steps.
538
Bruce Dawson425d4ab2023-06-25 01:36:15539### Improving performance of git commands
michaeldo8cccf2142017-03-06 22:12:02540
ishermance1d9d82017-05-12 23:10:04541#### Increase the vnode cache size
542
michaeldo8cccf2142017-03-06 22:12:02543`git status` is used frequently to determine the status of your checkout. Due
544to the large number of files in Chromium's checkout, `git status` performance
545can be quite variable. Increasing the system's vnode cache appears to help.
546By default, this command:
547
548```shell
549$ sysctl -a | egrep kern\..*vnodes
550```
551
552Outputs `kern.maxvnodes: 263168` (263168 is 257 * 1024). To increase this
553setting:
554
555```shell
556$ sudo sysctl kern.maxvnodes=$((512*1024))
557```
558
559Higher values may be appropriate if you routinely move between different
560Chromium checkouts. This setting will reset on reboot, the startup setting can
561be set in `/etc/sysctl.conf`:
562
563```shell
564$ echo kern.maxvnodes=$((512*1024)) | sudo tee -a /etc/sysctl.conf
565```
566
567Or edit the file directly.
568
ishermance1d9d82017-05-12 23:10:04569#### Configure git to use an untracked cache
570
Bruce Dawson2154274a2023-06-17 22:24:29571Try running
ishermance1d9d82017-05-12 23:10:04572
573```shell
574$ git update-index --test-untracked-cache
575```
576
577If the output ends with `OK`, then the following may also improve performance of
578`git status`:
579
580```shell
581$ git config core.untrackedCache true
582```
583
Tiago Vignatti760b0c02023-05-29 19:45:24584#### Configure git to use fsmonitor
585
Bruce Dawson2154274a2023-06-17 22:24:29586You can significantly speed up git by using [fsmonitor.](https://github.blog/2022-06-29-improve-git-monorepo-performance-with-a-file-system-monitor/)
587You should enable fsmonitor in large repos, such as Chromium and v8. Enabling
Avi Drissman9908ae442023-09-29 16:31:11588it globally will launch many processes and probably isn't worthwhile. Be sure
589you have at least version 2.43 (fsmonitor on the Mac is broken before then). The
Bruce Dawson2154274a2023-06-17 22:24:29590command to enable fsmonitor in the current repo is:
Tiago Vignatti760b0c02023-05-29 19:45:24591
592```shell
593$ git config core.fsmonitor true
594```
595
michaeldo8cccf2142017-03-06 22:12:02596### Xcode license agreement
597
598If you're getting the error
599
600> Agreeing to the Xcode/iOS license requires admin privileges, please re-run as
601> root via sudo.
602
603the Xcode license hasn't been accepted yet which (contrary to the message) any
604user can do by running:
605
606```shell
607$ xcodebuild -license
608```
609
610Only accepting for all users of the machine requires root:
611
612```shell
613$ sudo xcodebuild -license
614```