Even though it might look hard at first glance, it is actually a quite simple and straightforward process.
Let's have a look at how you can do it.
Installing XCode3It might seems odd but presently WebKit does not compiles with XCode4, Therefore the first thing you need to do is to retrieve and install XCode3. XCode3 will be your compilation tool as well as your IDE for WebKit development.
XCode3 is available in the Downloads section of the Apple Mac Dev Center.
Retrieving the sourcesOnce you have installed the right devtools, you can retrieve the WebKit sources.
Assuming you want the trunk, there is two ways to do it:
$svn checkouthttp://svn.webkit.org/repository/webkit/trunk WebKit
Retrieves the trunk of the subversion repository.
$curl -o WebKit-SVN-source.tar.bzhttp://nightly.webkit.org/files/WebKit-SVN-source.tar.bz2
$tar jxf WebKit-SVN-source.tar.bz2
Retrieves and unpack the latest nightly build.
Preparing the retrieved sources for buildingWhat you want is to build WebKit and put the resulting .framework bundles in your application bundle's Frameworks directory.
In order to do it, some preparation work is needed in the WebKit sources to ensure that the resulting dynamic libraries will be relocatable.
$find . -type f -name 'project.pbxproj' -exec sed -i 's/INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)"/INSTALL_PATH = "@rpath"/g'
Ensure that the Installation Path of dynamic libraries is relocatable otherwise you won't be able to include the built framework wherever you want to.
@rpath is a special identifier in MacOSX linking tools used to make dynamic libraries location agnostic.
Building the WebKitThis is probably the simplest part of the work. From the root directory of the repository, executes the following command:
It build WebKit in release mode. Now you can a coffe since the building takes some time...
Once done, we have some more work to do because WebCore.framework has to be included in WebKit.framework.
Go into the built sources directory.
$cp -R WebCore.framework WebKit.framework/Frameworks/
Copy the WebCore.framework in WebKit.framework so it can compile.
The only I still have at this point is that I need to have a duplicate WebCore.framework in both the Frameworks subdirectory of WebKit.framework bundle and a copy (which is also necessary in the final bundle) in the same directory than the others .framework.
At last, before building your application, you will simply have to set the Search Path to point to the directory in your bundle where you have copied your frameworks (typically Frameworks).