You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ios/native-xcode-node-folder/README.md
+18-3Lines changed: 18 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
An iOS Xcode project that uses the [`Node.js on Mobile`](https://github.com/janeasystems/nodejs-mobile) shared library, as an example of using a Node Project folder inside the Application.
4
4
5
-
The sample app runs the node.js engine in a background thread to start an HTTP server on port 3000 and return the `process.versions` value. The app's Main ViewController UI has a button to query the server and show the server's response. Alternatively, it's also possible to access the server from a browser running on a different device connected to the same local network.
5
+
The sample app runs the node.js engine in a background thread to start an HTTP server on port 3000 and return the `process.versions` value alongside the result of using the [`left-pad` npm module](https://www.npmjs.com/package/left-pad). The app's Main ViewController UI has a button to query the server and show the server's response. Alternatively, it's also possible to access the server from a browser running on a different device connected to the same local network.
6
6
7
7
## Prerequisites
8
8
To run the sample on iOS you need:
@@ -12,7 +12,8 @@ To run the sample on iOS you need:
12
12
13
13
## How to run
14
14
- Clone this project.
15
-
- Download the Node.js on Mobile shared library from [here](https://github.com/janeasystems/nodejs-mobile/releases/download/nodejs-mobile-v0.1.4/nodejs-mobile-v0.1.4-ios.zip).
15
+
- Run `npm install` inside `ios/native-xcode-node-folder/nodejs-project/`.
16
+
- Download the Node.js on Mobile shared library from [here](https://github.com/janeasystems/nodejs-mobile/releases/download/nodejs-mobile-v0.1.6/nodejs-mobile-v0.1.6-ios.zip).
16
17
- Copy the `NodeMobile.framework` file inside the zip's `Release-universal` path to this project's `NodeMobile/` folder (there's a `copy-NodeMobile.framework-here` empty file inside the project's folder for convenience).
17
18
- In Xcode import the `ios/native-xcode-node-folder/native-xcode-node-folder.xcodeproj` project.
18
19
- Select one physical iOS device as the run target.
@@ -49,7 +50,21 @@ versions_server.listen(3000);
49
50
}
50
51
```
51
52
52
-
> Having a `nodejs-project` path with a `package.json` inside is helpful for using npm modules, by running `npm install {module_name}` inside `nodejs-project` so that the modules are also packaged with the application and made available at runtime.
53
+
### Add an npm module to the `nodejs-project`
54
+
55
+
Having a `nodejs-project` path with a `package.json` inside is helpful for using npm modules, by running `npm install {module_name}` inside `nodejs-project` so that the modules are also packaged with the application and made available at runtime.
56
+
57
+
Install the `left-pad` module, by running `npm install left-pad` inside the `nodejs-project` folder.
58
+
59
+
Update `main.js` to use the module:
60
+
```js
61
+
var http =require('http');
62
+
var leftPad =require('left-pad');
63
+
var versions_server =http.createServer( (request, response) => {
0 commit comments