I'm working on an app where I'm going to use both HTML5 in UIWebView and native iOS framework together. I know that I can implement communication between JavaScript and Objective-C. Are there any libraries that simplify implementing this communication? I know that there are several libraries to create native iOS apps in HTML5 and javascript (for example AppMobi, PhoneGap), but I'm not sure if there is a library to help create native iOS apps with heavy JavaScript usage. I need to:

You can use WKWebView: call from javascript window.webkit.messageHandlers.{NAME}.postMessage(message) and then handle it with [WKUserContentController addScriptMessageHandler:name:] to call Objective-C from JS
–
kostylJun 11 at 19:14

However, I think it's something simple enough that you might give it a try yourself. I personally did exactly this when I needed to do that. You might also create a simple library that suits your needs.

From the above explanation, you see that if you want to do that, you have to create some JavaScript code, attach it to the event you want to monitor and call the correct window.location call to be then intercepted.

The suggested method of calling objective c from JS in the accepted answer isn't recommended. One example of problems: if you make two immediate consecutive calls one is ignored (you can't change location too quickly).

Not really: JavaScriptCore doesn't interact with UIWebViews. It's a great tool, but for a different class of problems. ;)
–
FollettoMar 6 '14 at 14:21

Yes it does: JSContext* context = [_webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"]; But JavaScriptCore is too buggy at the moment to be of any real use.
–
malcolmhallSep 4 '14 at 14:49

Your best bet is Appcelerators Titanium offering. They already have built a Obj-C javascript bridge using the V8 engine JavascriptCore engine used by webkit. It's also open source, so you'll be able to download it and tinker with the Obj-C as you like.

I created a library like WebViewJavascriptBridge, but it's more JQuery-like, has easier to setup and is easier to use. Doesn't rely on jQuery (though to its credit, had I known WebViewJavascriptBridge existed before writing this I may just have held back slightly before diving in). Let me know what you think! jockeyjs