📜 ⬆️ ⬇️

NodObjC - the bridge between Objective-C and Node.JS

I just wanted to shock you with my latest hacking achievements: I created a bidirectional bridge to the Objective-C runtime libraries from the Node environment. This crazy thing allows you to do great things, for example, writing native applications for MacOS X and iOS completely in Node and JavaScript!

I created a high-level library, which I called NodObjC , and it offers an easy-to-use API that is directly generated from the Objective-C libraries API. Here is an example from the README:
var $ = require('NodObjC'); // First you need to "import" the Framework $.import('Foundation'); // Setup the recommended NSAutoreleasePool instance var pool = $.NSAutoreleasePool('alloc')('init'); // NSStrings and JavaScript Strings are distinct objects, you must create an // NSString from a JS String when an Objective-C class method requires one. var string = $.NSString('stringWithUTF8String', 'Hello Objective-C World!'); // Print out the contents (calling [string description]) console.log('%s', string); // → Prints "Hello Objective-C World!" pool('drain'); 

Additionally, a low-level node-objc module is available, which provides access to the internals of the Objective-C execution library. I do not recommend using this API directly, it is just a module that NodObjC uses to implement its magic.

Both modules are still completely incomplete, but I have a good idea of ​​how to supplement them, and I just want to draw the attention of the community to this initiative. Please try and write to me to keep my motivation high !!!
')
Translator's Notes:

Source: https://habr.com/ru/post/127736/


All Articles