Skip to content

How to integrate Nodelike with MacGap

jeff-h edited this page Mar 7, 2014 · 4 revisions

MacGap (https://github.com/maccman/macgap) provides an Xcode project allowing native OS X apps to be written using standard webkit technologies. In addition, it provides a small Javascript API allowing OS integration with items such as native notifications, menus and window controls.

Nodelike can be combined MacGap, ultimately providing a javascript API that not only allows access to OS integration (menus, notifications, windows etc) but also access to the node.js API and the huge range of node modules.

Getting started

  • Download the repository at https://github.com/node-app/macgap which is a combination of MacGap and Nodelike.
  • Don't forget to pull in the Nodelike git submodules (http-parser and libuv)
  • open in Xcode, compile and run the app
  • right-click the resulting app, "Show package contents" and navigate to the public/index.html

Now, try the following code, which uses the fs node.js module to prove you have access to the node.js API. It should show an alert dialog box containing the name of the first file found in the /tmp directory.

var fs = require('fs');
fs.readdir('/tmp', function(e, files){
    alert(files[0]);
})