iPhone手机上搭建nodejs服务器步骤方法_node.js
一、为在ios上面运行,编译jxcore
$ mkdir ~/jxcore
$ cd ~/jxcore
$ git clone https://github.com/jxcore/jxcore.git
$ cd ~/jxcore/jxcore
$ ./build_scripts/ios-compile.sh
如果出现import which的module not found问题, 那就通过下面语句安装python的which
sudo easy_install tools/which-1.1.0-py2.7.egg
如果出现别的问题,可以参看jxcore编译ios的前提条件,采取相应措施。
https://github.com/jxcore/jxcore/blob/master/doc/HOW_TO_COMPILE.md
* 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)
二、 在mac上安装jxcore
$ ./configure
$ sudo make install
三、 创建cordova程序,如果没有安装cordova,可以自行安装。
$ cordova create hello com.example.hello HelloWorld
$ cd hello
四、下载安装jxcore-cordova插件
$ git clone https://github.com/jxcore/jxcore-cordova
利用jxcore-cordova的模板index.html
$ cp ./jxcore-cordova/sample/www/index.html ./www/
拷贝在第一步为在ios上运行而编译的jxcore包
$ cp -r ~/jxcore/jxcore/out_ios/ios/bin jxcore-cordova/io.jxcore.node/
五、添加cordova的ios platform
$ cordova platforms add ios
$ cordova plugin add jxcore-cordova/io.jxcore.node/
$ cordova build
$ cordova run ios
如果build出错,"C does not support default arguments"
只需将默认值去掉一般就会解决问题。
将
JXCORE_EXTERN(void)
JX_SetString(JXValue *value, const char *val, const int32_t length = 0);
修改为
JXCORE_EXTERN(void)
JX_SetString(JXValue *value, const char *val, const int32_t length);
重新build即可
六、此时应该可以看到cordova的运行界面。
七、在Resources/jxcore_app/app.js添加nodejs server
在app.js的最后面添加如下代码
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/');
运行程序,即可在xcode的log信息里面看到iphone的ip,然后通过网页就可以浏览网页。

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

苹果终于揭开了其新款高端 iPhone 机型的面纱。与上一代产品相比,iPhone 16 Pro 和 iPhone 16 Pro Max 现在配备了更大的屏幕(Pro 为 6.3 英寸,Pro Max 为 6.9 英寸)。他们获得了增强版 Apple A1

今年早些时候,苹果宣布将把激活锁功能扩展到 iPhone 组件。这有效地将各个 iPhone 组件(例如电池、显示屏、FaceID 组件和相机硬件)链接到 iCloud 帐户,

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,

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 官网注册并下载最新 App 的步骤。首先介绍了注册流程,包括填写注册信息、验证邮箱/手机号码,以及完成注册。其次讲解了下载 iOS 设备和 Android 设备上 Gate.io App 的方法。最后强调了安全提示,如验证官网真实性、启用两步验证以及警惕钓鱼风险,以确保用户账户和资产安全。

Beats 以推出蓝牙扬声器和耳机等音频产品而闻名,但令人惊讶的是,这家苹果旗下公司从 iPhone 16 系列开始涉足手机壳制造领域。节拍 iPhone

币安App官方安装步骤:安卓需访官网找下载链接,选安卓版下载安装;iOS在App Store搜“Binance”下载。均要从官方渠道,留意协议。

问题介绍在使用PHP调用支付宝EasySDK时,按照官方提供的代码填入参数后,运行过程中遇到报错信息“Undefined...
