Archive

nodejs on iphone running localhost webapp

I have been doing a lot of HTML5 web apps in iOS lately, running them from both remote hots and via phonegap, but now I have take a totally different approach: being a node.js fan, I decided to hack my iphone just so that I could run nodejs on it. It works great, you can run version 6.x and even allows you to do npm. So to bring it all together, I copied my webapp to my iphone and ran it as a nodejs server, loading then on local host in the browser... it even supports websockets (socket.io). This is little different than Nathan Rajlich (the author of the node.js iphone package port) took, when trying to tackle directly into the phone's native APIs. I am keeping the spirit of a webapp, while still having more options than classic webapp or phonegap approach.

Here are a few screenshots:



Here are the steps to get there:

1. Jailbrake you iphone

2. install open shh (available in the syndia app store)

3. install node.js 6.x (available in the syndia app store) (the package comes with npm)

4. get the SSH Terminal via iTunes appstore ($0.99)

5. connect to wifi, look in your settings for the phone's ip address, and then you can login into your iphone (both via ssh and ftp. The default login for every iphone are: login: root: alpine (at this point recommend changing password so you don't get hacked :)

passwd root

Enter new password...

6. at this point you should have both ssh and ftp access to your phone, so go ahead, npm install your favorite packages, and copy over your node.js project. (recommend keeping the phone plugged in, otherwise it will keep shutting off the wifi connection, and you will need to reset your ip address all the time)

7. Either remotely, or locally (from your phone), start your node.js server.

In conclusion: if this solution got packaged into a simple SDK (daemon running, starting node server via an icon) I could see some great possibilities. Both, native HTML5 apps, and phonegap apps have their limitations, this way you could load all your resources locally, go to the network when needed, plus have much more power over the network communications, like connecting to mongoDb directly, running websockets from localhost... the main benefit about this "all JavaScript" solution is really the easy and speed of development... you can write relatively complex apps in hours...

Comments: