12

I'm using WebKit in an OS X app via the JUCE WebBrowserComponent, a lightweight wrapper around Apple's WebView Objective-C class. I'm compiling on OS X 10.12 with a deployment target of 10.7.

The issue I'm having is that on OS X 10.8, the version of WebKit used by the WebView seems to be different to that used by Safari and I can't figure out how the WebKit version is selected or why they are different.

Running otool -L on Safari, gives me:

otool -L /System/Library/PrivateFrameworks/Safari.framework/Versions/A/Safari | grep WebKit
    /System/Library/Frameworks/WebKit.framework/Versions/A/WebKit (compatibility version 1.0.0, current version 536.30.1)
    /System/Library/PrivateFrameworks/WebKit2.framework/Versions/A/WebKit2 (compatibility version 1.0.0, current version 536.30.1)

Running otool -L on the Juce demo gives me:

otool -L JuceDemo | grep WebKit
    /System/Library/Frameworks/WebKit.framework/Versions/A/WebKit (compatibility version 1.0.0, current version 602.2.14)

Firstly, why are the "current version" numbers different, for apparently the same linked framework?

Also, if I point the respective applications at http://browserspy.dk/webkit.php It gives me a AppleWebKit version of 600.8.9 for Safari and a version of 536.30.1 for JUCE Demo.

What accounts for these different version numbers, and how can I configure my application so that my WebView uses the "600.8.9" version of WebKit used by Safari?

j b
  • 5,147
  • 5
  • 41
  • 60

1 Answers1

8

otool version

The current version that otool outputs is the version that was used to link when the app was build.

Safari, WebKit and everything

On the latest macOS release Safari uses the system WebKit version. So macOS Sierra 10.12 with Safari 10 uses /System/Library/Frameworks/WebKit.

Safari also supports older macOS releases. And is updated independently from the system. For example Safari 10 runs on macOS 10.10, 10.11 and 10.12. Now macOS 10.11 was released with Safari 9, but when Safari 10 is installed it uses not the system WebKit. Instead a version in /System/Library/StagedFrameworks/Safari is used.

Why?

New major Safari versions not only add shiny new features, and bugs, they sometimes also remove things. Some ill faded -webkit prefixes come to mind. WebKit is part of the SDK which guaranties you that your app will not break on such updates.

Testing

Here the version output of a test app from WebView and WKWebView:

macOS 10.8.5 (12F2560):

Safari Version 6.2.8 (8537.85.17.9.1)
WebKit Version 600.8.9

Cocoa App
WebView WebKit Version 536.30.1

macOS 10.9.5 (13F1911):

Safari Version 9.1.3 (9537.86.7.8)
WebKit Version 601.7.8

Cocoa App
WebView WebKit Version 537.78.2

macOS 10.10.5 (14F2009):

Safari Version 10.0.1 (10602.2.14.0.7)
WebKit Version 602.2.14

Cocoa App
WebView WebKit Version 600.8.9
WKWebView WebKit Version 600.8.9

macOS 10.11.6 (15G1108):

Safari Version 10.0.1 (11602.2.14.0.7)
WebKit Version 602.2.14

Cocoa App
WebView WebKit Version 601.7.8
WKWebView WebKit Version 601.7.8

Answer

It is not supported to link your app to the Safari WebKit version.

You could include your own WebKit build. But I think it's simpler to write your web code for the old version of your deployment target.

catlan
  • 25,100
  • 8
  • 67
  • 78
  • Thanks. re: "As far as I know you cannot link your app to the Safari WebKit version" — unless Safari is statically linking to WebKit (which I doubt), then this can't be true, can it? Presumably the version in `/System/Library/PrivateFrameworks` is the one supplying Safari with the updated functionality? As an experiment I tried pointing my app at that with `install_name_tool`, but I get `dyld: Symbol not found: _OBJC_CLASS_$_WebView`. So, I guess the fact Safari links to both versions is somehow significant. Any idea how to do that? – j b Mar 08 '17 at 10:52
  • Honest I was surprised myself when I looked into it. I expected Safari to include it's own version of WebKit - like the Safari Technology Preview. But this doesn't change anything: The SDK provides you with WebView and WKWebView with a specific WebKit version. Not always the latest and greatest Safari WebKit version. – catlan Mar 08 '17 at 12:12
  • OK, I've marked this as accepted, because I think you're right, what I'm asking in my question isn't possible, or at least it isn't supported. – j b Mar 08 '17 at 17:00
  • If I figure out how this is done I let you know. Your deployment target seems super old, well, I only drop 10.8 three month ago so I know how this goes. Maybe rethinking that makes the webkit version less of an issue. – catlan Mar 08 '17 at 17:11
  • Thanks and yeah. We don't *currently* support 10.8, but we have users requesting it and this is the showstopper – j b Mar 08 '17 at 17:13
  • Assuming I did want to include my own WebKit build, how would I do that? Is it just a case of downloading a nightly build, linking to the included frameworks and bundling them with my app? – j b Mar 09 '17 at 09:48
  • I haven't done this myself, so I don't know. But you are trying to get new WebKit version working on an old macOS so I'm sure it would be significant amount of work. – catlan Mar 09 '17 at 10:20
  • @JamieBullock not sure how I overlooked it the first time but I found it: /System/Library/StagedFrameworks/Safari. – catlan Mar 09 '17 at 18:31
  • Both WebView and WKWebview on macOS 10.13.4 gives WebKit 605.1.15. I don’t have macOS 10.12 with me. – Franklin Yu Apr 11 '18 at 02:40
  • `Assuming I did want to include my own WebKit build, how would I do that?` - OLD thread, but I have a hunch you can't. AFAIK Apple's WebKit `port` uses ObjC and newer versions are bound to use newer ObjC features that requirer newer versions of the Mac OS. (Incidentally, THE big reason why ObjC will sadly not see more widespread use outside the Apple universe, IMHO.) – RJVB Jun 08 '20 at 14:27