Home Web Front-end JS Tutorial Steps and methods to build nodejs server on iPhone_node.js

Steps and methods to build nodejs server on iPhone_node.js

May 16, 2016 pm 03:51 PM
iphone cell phone

1. To run on ios, compile jxcore

Copy code The code is as follows:

$ mkdir ~/jxcore
$ cd ~/jxcore
$ git clone https://github.com/jxcore/jxcore.git


Copy code The code is as follows:

$ cd ~/jxcore/jxcore
$ ./build_scripts/ios-compile.sh

If there is a problem with import which module not found, then install python which

through the following statement

Copy code The code is as follows:

sudo easy_install tools/which-1.1.0-py2.7.egg

If other problems occur, you can refer to the prerequisites for compiling ios with jxcore and take corresponding measures.
https://github.com/jxcore/jxcore/blob/master/doc/HOW_TO_COMPILE.md


Copy code The code is as follows:

* GCC 4.2 or newer (for SpiderMonkey builds 4.7 )
* Python 2.6 or 2.7
* GNU Make 3.81 or newer
* libexecinfo (FreeBSD and OpenBSD only)
* for SpiderMonkey: 'which' python module (sudo easy_install tools/which-1.1.0-py2.7.egg)

2. Install jxcore on mac

Copy code The code is as follows:

$ ./configure
$ sudo make install

3. Create the cordova program. If cordova is not installed, you can install it yourself.

Copy code The code is as follows:

$ cordova create hello com.example.hello HelloWorld
$ cd hello

4. Download and install the jxcore-cordova plug-in

Copy code The code is as follows:

$ git clone https://github.com/jxcore/jxcore-cordova

Using jxcore-cordova’s template index.html
Copy code The code is as follows:

$ cp ./jxcore-cordova/sample/www/index.html ./www/

Copy the jxcore package compiled for running on ios in the first step
Copy code The code is as follows:

$ cp -r ~/jxcore/jxcore/out_ios/ios/bin jxcore-cordova/io.jxcore.node/

5. Add cordova’s ios platform
Copy code The code is as follows:

$ cordova platforms add ios
$ cordova plugin add jxcore-cordova/io.jxcore.node/
$ cordova build
$ cordova run ios

If the build error occurs, "C does not support default arguments"

Just removing the default value will usually solve the problem.

will

Copy code The code is as follows:

JXCORE_EXTERN(void)
JX_SetString(JXValue *value, const char *val, const int32_t length = 0);

Modify to
Copy code The code is as follows:

JXCORE_EXTERN(void)
JX_SetString(JXValue *value, const char *val, const int32_t length);

Just rebuild

6. You should be able to see the cordova running interface at this time.
7. Add nodejs server in Resources/jxcore_app/app.js

Add the following code at the end of app.js

Copy code The code is as follows:

function getIP() {
        var os = require('os');  
      var nets = os.networkInterfaces();
console.log(nets);
for ( var a in nets) {
              var ifaces = nets[a];
for (var o in ifaces) {
If (ifaces[o].family == "IPv4" && !ifaces[o].internal) { return ifaces[o].address; }
                                                                                                                                                                                                                                                        return null;                                }
var ip = getIP();
if (!ip) {
console.error("You should connect to a network!");
Return;
}

var http = require('http');
http.createServer(function(req, res) {
          res.writeHead(200, {                                     ‘Content-Type’: ‘text/plain’
         }); 
      var cur_client = "";  
If(req.connection && req.connection.remoteAddress) {
console.log(req.connection.remoteAddress);
                                                                                                                                                                                                                     cur_client = req.connection.remoteAddress;             } else if(req.headers) { 
console.log("request header X-Forwarded-For");
console.log(req.headers['X-Forwarded-For']);
                                                                                                                                                                                                                                                     cur_client = req.headers['X-Forwarded-For'];                                                                                                                        cordova('log').call('client( ' cur_client ' ) come');
res.end('Hello ' cur_client ', I am server on iphone app(' ip '). ' Date.now() 'n');
}).listen(1337, ip);
console.log('Server running at http://' ip ':1337/');


Run the program, you can see the iPhone's IP in the xcode log information, and then you can browse the web through the web page.
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

iPhone 16 Pro and iPhone 16 Pro Max official with new cameras, A18 Pro SoC and larger screens iPhone 16 Pro and iPhone 16 Pro Max official with new cameras, A18 Pro SoC and larger screens Sep 10, 2024 am 06:50 AM

Apple has finally lifted the covers off its new high-end iPhone models. The iPhone 16 Pro and iPhone 16 Pro Max now come with larger screens compared to their last-gen counterparts (6.3-in on the Pro, 6.9-in on Pro Max). They get an enhanced Apple A1

iPhone parts Activation Lock spotted in iOS 18 RC — may be Apple\'s latest blow to right to repair sold under the guise of user protection iPhone parts Activation Lock spotted in iOS 18 RC — may be Apple\'s latest blow to right to repair sold under the guise of user protection Sep 14, 2024 am 06:29 AM

Earlier this year, Apple announced that it would be expanding its Activation Lock feature to iPhone components. This effectively links individual iPhone components, like the battery, display, FaceID assembly, and camera hardware to an iCloud account,

iPhone parts Activation Lock may be Apple\'s latest blow to right to repair sold under the guise of user protection iPhone parts Activation Lock may be Apple\'s latest blow to right to repair sold under the guise of user protection Sep 13, 2024 pm 06:17 PM

Earlier this year, Apple announced that it would be expanding its Activation Lock feature to iPhone components. This effectively links individual iPhone components, like the battery, display, FaceID assembly, and camera hardware to an iCloud account,

Multiple iPhone 16 Pro users report touchscreen freezing issues, possibly linked to palm rejection sensitivity Multiple iPhone 16 Pro users report touchscreen freezing issues, possibly linked to palm rejection sensitivity Sep 23, 2024 pm 06:18 PM

If you've already gotten your hands on a device from the Apple's iPhone 16 lineup — more specifically, the 16 Pro/Pro Max — chances are you've recently faced some kind of issue with the touchscreen. The silver lining is that you're not alone—reports

Gate.io trading platform official app download and installation address Gate.io trading platform official app download and installation address Feb 13, 2025 pm 07:33 PM

This article details the steps to register and download the latest app on the official website of Gate.io. First, the registration process is introduced, including filling in the registration information, verifying the email/mobile phone number, and completing the registration. Secondly, it explains how to download the Gate.io App on iOS devices and Android devices. Finally, security tips are emphasized, such as verifying the authenticity of the official website, enabling two-step verification, and being alert to phishing risks to ensure the safety of user accounts and assets.

Beats adds phone cases to its lineup: unveils a MagSafe case for the iPhone 16 series Beats adds phone cases to its lineup: unveils a MagSafe case for the iPhone 16 series Sep 11, 2024 pm 03:33 PM

Beats is known for launching audio products such as Bluetooth speakers and headphones, but in what can best be described as a surprise, the Apple-owned company has branched into making phone cases, starting with the iPhone 16 series. The Beats iPhone

How to solve the problem of 'Undefined array key 'sign'' error when calling Alipay EasySDK using PHP? How to solve the problem of 'Undefined array key 'sign'' error when calling Alipay EasySDK using PHP? Mar 31, 2025 pm 11:51 PM

Problem Description When calling Alipay EasySDK using PHP, after filling in the parameters according to the official code, an error message was reported during operation: "Undefined...

Anbi app official download v2.96.2 latest version installation Anbi official Android version Anbi app official download v2.96.2 latest version installation Anbi official Android version Mar 04, 2025 pm 01:06 PM

Binance App official installation steps: Android needs to visit the official website to find the download link, choose the Android version to download and install; iOS search for "Binance" on the App Store. All should pay attention to the agreement through official channels.

See all articles