Get Updates By E-mail 

Article Written By:
Johann Dowa

Scripts For Generating Javascript and C/Objective-C Bindings


Last week I mentioned news about some major Cocos2D updates allowing you to use Javascript as a scripting language.

Recently Zynga also released a related set of scripts called Javascript Bindings for C/Objective-C (for any code – not just Cocos2D).

With the Javascript Bindings for C/Objective-C you can access your Objective-C code from JavaScript, and vice versa.

The really cool thing about this library vs. other solutions for working with Javascript through Objective-C is that  you don’t have to modify the source code of your libraries as the included scripts do the work for you, and the Javascript is interpreted through Mozilla’s SpiderMonkey.

Here’s a list of highlights from the read me:

– Supports any Objective-C / C library
– Automatically generates the JS bindings (“glue” code)
– No need to modify the source code of your libraries, or the autogenerated code
– Powerful set of rules to customize the generated JS API
– Automatically converts JS objects/types into Objective-C – –objects/structs/ types and vice-versa
– Supports “subclassing” native objects in JS
– Supports callbacks
– Automatically generates object oriented JS API from C libraries (provided that the C API is OO, like Chipmunk)

You can find Javascript Bindings for C/Objective-C on Github here.

You’ll also need SpiderMonkey (the SpiderMonkey link in the readme appears incorrect but I believe this is the right version) and JRSwizzle.

Full details on how to generate the bindings and use them in your projects are on the Github page along with some examples.


Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.