One of the cooler things that's happened at WWDC this week (other than that minor Monday announcement) is the launch of a new Apple open-source site. The WebKit Open Source Project is the new home of all work on WebKit, WebCore and JavaScriptCore. These are the frameworks behind Safari (and other applications). This is exciting for a number of reasons -- bugs and fixes are now publicly viewable, and if you're much brighter than I am, you can even modify the code and submit bug fixes and new features back to Apple for possible inclusion in the next official Safari release. But since I lack such skills, I found the most interesting bit to be this: you can now build your own version of Safari from code that's newer than the latest public release.
Why might you want to do this? Because the Safari team is constantly rolling fixes and enhancements into the code base, and sometimes, it's nice to have those new features now rather than later. Consider, for instance, the browser stress-test known as the Acid2 Browser Test. This test is designed to see how well browsers support some of the more leading-edge features of HTML and CSS, and how well they deal with errors in such code. The final output is quite simple -- a smiling face. But it's built using some complex code, and not many browsers do very well at it.
Below is a comparision picture showing how well the two versions of Safari do at the test. On the left is the released version of Safari, in the middle is the built-from-source version of Safari, and on the right is the ideal "reference image" for what you should see.
![]() |
![]() |
![]() |
The Getting the Code and Building Webkit pages of the Apple site contains detailed instructions on exactly what you'll need to do. If you have lots of experience with compiling applications, just head over there and follow their directions. I'll repeat their instructions here, with added details based on my experience. I'm assuming you have XCode installed (version 2.0, not the newly available 2.1. If you have 2.1, you'll need to modify the installation process), the Terminal open, and that you know how to edit files in the Terminal. I'm also assuming you have not checked things out from CVS (see below) before, nor have your own already-existing builds directory. If any of the above is false, modify these instructions based on your setup.
$ cd ~ /* change to your home directory, just in case you're not there. */
$ touch .cvspass /* required to make CVS access work -- only needed once */
$ mkdir builds /* the new build directory; do not put spaces in its name */
$ cd builds /* change to build directory */
$ cvs -d :pserver:anonymous@anoncvs.opensource.apple.com:/cvs/root login
/* the above command connects to Apple's WebKit CVS. Enter 'anonymous' */
/* for the password when prompted. */
$ cvs -d :pserver:anonymous@anoncvs.opensource.apple.com:/cvs/root co -P WebKitTools
/* check out (download) the WebKitTools module */
$ WebKitTools/checkout /* this script does the rest of the hard work */
The last step will start a long string of onscreen updates, and when it's done, you'll have the WebKit files on your local machine. Once you've done this once, you can update your version at any point by running this command from the builds directory: WebKitTools/Scripts/update-webkitCan't find executable at /Users/robg/builds/Deployment/JavaScriptCore.framework/
Versions/A/JavaScriptCore; have you built successfully?
Since I'd just watched the compile finish, I knew I'd built successfully. Thanks to nkuvu in this thread on the macosxhints' forums for finding the cure. For both he and I, a modification to the run-safari script was required. I haven't seen this mentioned elsewhere, so I'm not sure why. But the fix is quite simple. Navigate into the WebKitTools/Scripts folder, and open run-safari with your favorite editor. Jump to line 48, which will look like this:
$productDir = "$productDir/Deployment";
Change it to this:
$productDir = "$productDir";
Save the file, quit the editor, and try the script again. Bingo! Welcome to the new Safari. From now on, just use run-safari when you want to load Safari with the new frameworks, and double-click Safari's dock icon to run it with the old frameworks. The version I built last night seems quite stable, and I haven't found any obvious bugs yet (though I'm sure there may be some in there). I don't intend to build a new one every night, but I will keep an eye on Surfin' Safari, which is Safari lead engineer's Dave Hyatt's blog, for any notable updates to the source.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20050608011731299