iOS JavaScript Bridge

Last Updated on January 27th, 2012 (sub-pages have their own dates)

What Does It Do?

Enables method calls and communication between JavaScript & Objective-C. Allows you to write application logic in JavaScript and control native device features via JS to Obj-C calls.

How Does It Work?

Your JS is contained and executed inside a custom build of JavaScriptCore so that no private API calls are made (and therefore your project can be deployed to the Apple App Store). No webview is presented to the user by default so your app does not “run” inside a web browser.

Instead you can create your application logic and call native methods entirely in JavaScript. This opens up a number of possibilities such as allowing JavaScript to control OpenGL output making game engines that are coded in JavaScript capable of using native-speed graphics output instead of using Safari and the HTML canvas tag.

Future Plans?

Right now, any methods that you expose to JavaScript must be written by yourself so an understanding of Objective-C is required. Future versions of this project will expose a rich API to your JavaScript code to allow control of the most useful native capabilities of the device.

As the project progresses many more features will be added to the list. The main priorities of this project are to make these features available to JavaScript as an API:

  • Mimic canvas-tag methods to output graphics via OpenGL.
  • Mimic audio-tag methods to output sound via OpenAL.
  • Provide a clean and easy networking API to JavaScript to utilise native sockets capability.

Links

  • Thomas

    Hi, I’m trying to integrate your JavaScript Bridge into a simple HelloWorld app (mimicking your JSCDemo, even copying the JSCBinding files), but I’m getting linker errors

    Undefined symbols for architecture i386:
      “typeinfo for JSC::JSObject”, referenced from:
          typeinfo for JSC::JSNonFinalObjectin JSCBindingImpl.o
      “typeinfo for JSC::JSGlobalObject”, referenced from:
          typeinfo for GlobalObjectin JSCBindingImpl.o
      “typeinfo for JSC::WeakHandleOwner”, referenced from:
          typeinfo for JSC::WeakGCMap<void*, JSC::JSObject, JSC::DefaultWeakGCMapFinalizerCallback, WTF::PtrHash, WTF::HashTraits >in JSCBindingImpl.o
    ld: symbol(s) not found for architecture i386
    collect2: ld returned 1 exit status

    Any idea what I’m missing here?
    Thomas

  • Thomas

    Found it – I had to disable C++ Runtime Types (in Section LLVM GCC 4.2 – Language)

  • Fcinter

    I can’t compile the project with Xcode 4.2, the errors are:
    ‘::mbstate_t’ has not been declared
    ‘::btowc’ has not been declared

    I guess it’s caused by some unicode library, is it possible to fix it in github?

    • Fcinter

      Found the solution. The errors went away after I renamed wchar.h

      • http://www.isogenicengine.com Rob Evans

        Many thanks for your solution and for posting it here for others, seriously awesome. :)

        Are you using this project in an app? We’d love to hear your feedback / use case!

      • Pole

         What file did you renamed?