Building WebKit
Building WebKit requires that you have the proper developer tools installed and that you have a copy of the WebKit source tree. Run the build-webkit script to build WebKit. Use the --debug option for a debug build, which includes debugging symbols and assertions, or --release for an optimized build:
build-webkit --debug
By default, build-webkit places build products in WebKitBuild. You can specify a different build location on Mac in your Xcode preferences. On other platforms, the WEBKIT_OUTPUTDIR environment variable can be used to set a different build products location. If you have set up a custom build location, then build-webkit will place the build products there.
Note: Many build problems can be solved by updating your build tools and/or deleting the WebKitBuild directory and starting from scratch.
Once your build has finished, you can run Safari using your custom WebKit build. Don’t forget that if you have any questions or problems building WebKit, feel free to get in touch!
MacOS
By default, MacOS builds use Xcode’s build system. If you want to try the experimental cmake build system for MacOS (much faster, but also more likely to fail), just pass in --cmake.
build-webkit --debug --cmake
You can also open WebKit.xcworkspace to build and debug WebKit within Xcode.
Select the “Everything up to WebKit + Tools” scheme to build the entire
project.
If you don’t use a custom build location in Xcode preferences, you have to
update the workspace settings to use WebKitBuild directory. In the menu bar,
choose File > Workspace Settings, then click the Advanced button, select
“Custom”, “Relative to Workspace”, and enter WebKitBuild for both Products
and Intermediates.
Windows
Building on Windows requires a few more steps. For details, see https://docs.webkit.org/Ports/WindowsPort.html.
Embedded Platform Builds
To build for an embedded platform like iOS, tvOS, or watchOS, pass a platform
argument to build-webkit.
For example, to build a debug build with debugging symbols and assertions for
iOS simulator:
build-webkit --debug --ios-simulator
or iOS devices:
build-webkit --debug --ios-device
build-webkit --help shows all platform arguments. Note that while simulator builds will be able to be run in the matching simulated device type, device builds of WebKit cannot be installed on embedded devices.
Setting a Default Configuration
To set a default build configuration for build-webkit and other scripts, use the set-webkit-configuration script:
set-webkit-configuration --debug
set-webkit-configuration --release