4 ms·
Totally agree it's more like an evolution, and I doubt it will be exposed on iOS at all, which means the same developer rules will apply and downloaded JS will
by yoda_sl 13y ago
Totally agree it's more like an evolution, and I doubt it will be exposed on iOS at all, which means the same developer rules will apply and downloaded JS will have to be running inside a UIWebView.
The fact is that after thinking about the iOS developer rules and what is currently available in iOS, it's totally doable to write a true Javascript bridge that respect all the requirement from the iOS rules and still let your JS code access all the ObjC runtime, in a totally transparent way aka I am able to write the following:
var userName = userNameTextfield.getText();
var helloMsg = "Hello " + userName;
messageLabel.setText(helloMsg);
The first line will directly get the text value of a UITextField (no callback used here), and it will end up calling directly the 'text' property on the UITextField. So the JS bridge works transparently where JS code call native ObjC code directly (without using callback) and obviously ObjC can directly access the JS side... there are a few gotcha but the full system works beautifully and surprising enough performance are quite good. It took me a few years to come up with the cleanest solution and implementation.
I am currently working on integrating such piece of code into some of my apps and have them released on the AppStore. In fact if anyone good in JS is interested I would really appreciate some help to get that bridge off the ground since I truly believe there is a lot of great opportunities with a JS bridge to ObjC that respect all iOS rules.
My contact info are my HN profile.
Edit: minor typo fixed
- ryanpetrich 13y agoSynchronous XMLHTTPRequest connected to an NSURLProtocol?
- orta 13y agoI accepted a pod to cocoapods recently that does most of what you're after: https://github.com/marcuswestin/WebViewJavascriptBridge https://github.com/marcuswestin/WebViewJavascriptBridge