0

Is it ok to use the Webkit Javascript engine to implement cross-platform, non-GUI backend functionality on the iPhone, iPad? In my case, I was interested in re-using Javascript code that I have that works on top of SQLite. I thought I would need to re-implement the logic in Obj-C but perhaps I could just share it and expose some hooks into Obj-C using JSCocoa or straight through JavaScript core. If I do this, is it ok to bypass the UIWebView control and go straight to JavaScriptCore or is that still considered a private framework? I am still searching and will update this if I find the answer.

5
  • 1
    Questions like this make me very sad. Oh Apple, what have you done... Commented May 11, 2010 at 16:54
  • Matti, to answer: created one of the most profitable and powerful opportunities for developers ever. Did developers ever make money on mobile before Apple. Uhh, no. Ok back to my question. Commented May 11, 2010 at 17:02
  • @John Wright: I take it their TOS now requires developers to post defensive comments about their draconian policies, lest their apps all mysteriously disappear and any iPhones in their possession explode? Commented May 11, 2010 at 17:07
  • @John Wright: Yeah, Steve Jobs sure is the creative genius of the century ¬__¬ Commented May 11, 2010 at 17:23
  • Is it OK? Assuming you are talking about in relation to the updated SDK Agreement, probably. Is it going to be a good longterm solution? I don't know. It is quite possible that Apple could be wise to your "scheme" and reject your app for minimal functionality. Personally, I think you may be playing with fire. Commented May 11, 2010 at 17:42

2 Answers 2

1

Although the iPhone uses WebKit, UIWebView does not expose it as a public interface. To strictly follow apple guidelines, the only communication between a web page and the host application is by calling eval with stringByEvaluatingJavaScriptFromString and by processing resource requests.

You can do a lot in javascript. In fact, when it comes to controlling a UIWebView, javascript can often do more than Objective-C. If your communications with the host application are simple enough you should be able to keep your existing code with minimal changes.

Sign up to request clarification or add additional context in comments.

1 Comment

My interface with the host app would be fairly minimal but it seems silly to have to use a Webkit control. Thanks for this good answer.
0

I'm pretty sure it is legal, in fact I have done this recently for a project at my company. We had a GWT app which spat out a JavaScript/HTML application which we needed to be port to iPhone and Android. Rather than doing a complete rewrite on each platform, we went down the (slightly insane) route of keeping the Java/JavaScript backend and sticking on native code to handle the UI. Works well and you can't tell that in the background it is a browser that is running the show.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.