7

Apple has (partly) open sourced the WebKit and JavaScriptCore engine they use in iOS: http://www.opensource.apple.com/release/ios-433/

It is already possible to build, use, and ship your own version of JavaScriptCore on iOS. Is it, however, possible to do the same with the rendering engine of WebKit? The UIWebView on iOS is very limited. The vital feature it is missing is accessing the JavaScriptCore JavaScript context object. Without it, it's close to impossible to run some code directly in JavaScriptCore and some code in the web view while sharing the same JS engine. So I'm interested in building my own WebKit-based web view that exposes the JavaScript context.

Are there any projects that have done any work in this regard yet? Would the compiled web view library be far too big to ship with an app?

Thanks!

Johannes Fahrenkrug
  • 42,912
  • 19
  • 126
  • 165

3 Answers3

2

It is possible, but not allowed by Apple. For the same official reasons that they did not allow Google to ship their own WebKit version with their browser. Google has to use UIWebView.

daniel.gindi
  • 3,457
  • 1
  • 30
  • 36
  • That is true. However, I am mainly interested in the technical aspects, even if Apple wouldn't allow it to be put on the App Store. – Johannes Fahrenkrug May 29 '14 at 13:36
  • Then in this case it is possible like almost anything else... :-) It would be a lot of work of course, because a Browser is not just a WebKit renderer and a JavaScript (V8?...) engine. It handles a lot of networking stuff, SSLs, and that's the simple stuff! – daniel.gindi May 29 '14 at 15:20
  • Naturally it is _possible_, but is it feasible to build WebKit from source for iOS? Compiling and running JavaScriptCore for iOS is not a problem and networking is not a problem either. But building the HTML rendering engine from source and getting it up and running: That's the big question :) – Johannes Fahrenkrug May 29 '14 at 17:49
  • Well, it is already written to be compiled for iOS! Proof is Mobile Safari. So there's absolutely no reason why you wouldn't be able to do so *easily*! – daniel.gindi May 29 '14 at 17:54
  • The real question is - would you be satisfied with just a *rendering* engine? What if you build connect it to JS, and find out that XHR doesn't work because you did not implement any networking code? Or that HTML5 Video does not work because you didn't bind it to proper codecs? – daniel.gindi May 29 '14 at 17:56
  • Well, I'd be happy if I'd just be able to render a basic HTML document with a compiled-from-source-WebKit on iOS. If it really is that easy, I'm surprised that in the three years since I asked the question no one has was able to provide those easy instructions. If you know how to do it easily, please post an answer with the instructions! That would be great! – Johannes Fahrenkrug May 29 '14 at 19:52
  • I'll find some time next week and let you know :-) – daniel.gindi May 29 '14 at 20:37
  • Btw, have you tried this? http://opensource.apple.com/source/WebCore/WebCore-1640.28/ The official Apple WebKit release. It already COMPILED! You have the A library files there in the folder, and you can take all the H's you need. You can easily create a Framework folder from it... – daniel.gindi May 30 '14 at 10:26
  • Yes, but it is still a ways away to get something up on the screen. Plus, if I just wanted to use the pre-compiled version, I could just link to the private WebCore framework that ships with iOS. Compiling it from source is a different beast: Apple didn't open-source their Makefiles.. – Johannes Fahrenkrug May 30 '14 at 11:59
2

This is very feasible. In fact, it has already been done. Impact is an iOS game engine that compiles its own JavaScript core. Here's a blog post with some technical details.

I won't elaborate further here, the links should provide more than enough detail.

August Lilleaas
  • 54,010
  • 13
  • 102
  • 111
  • Thanks for your answer, but that's not what I'm looking for. I know about Impact and I'm using their build of JavaScriptCore in my app. What I want is build my own UIWebView from source, the full html rendering engine and all, not just the JS engine. – Johannes Fahrenkrug Jul 28 '11 at 12:29
-2

I guess unfortunately the answer is no.

The question was whether it's feasible or not. Based on not receiving any answers and not finding any information online I concluded that it would not be impossible but far too much work to be feasible.

Johannes Fahrenkrug
  • 42,912
  • 19
  • 126
  • 165
  • You came to this conclusion because no one answered your question, or do you also have other information? – Matthew Gertner Dec 30 '12 at 12:46
  • @MatthewGertner The question was whether it's _feasible_ or not. Based on not receiving any answers and not finding any information online I concluded that it would be not be _impossible_ but far too much work :( – Johannes Fahrenkrug Dec 31 '12 at 18:58