简体   繁体   English

将iPhone连接到本地主机

[英]Connect iPhone to localhost

I am trying to connect my test device to my local server -- and while the simulator works fine accessing localhost:8000, I can't seem to connect from the device. 我正在尝试将测试设备连接到本地服务器-虽然模拟器可以很好地访问localhost:8000,但似乎无法从设备进行连接。 This despite the fact that the device and my computer are both connected to the same wifi network. 尽管设备和我的计算机都连接到了同一个wifi网络,但事实并非如此。

So far, I have tried to get this to work by going to system prefs -> network -> grabbing the IP address from where it says 'Wi-Fi is connected to myWifiNetwork and has the IP address 10.0.0.52'. 到目前为止,我已经尝试通过进入系统偏好设置->网络->从“ Wi-Fi已连接到myWifiNetwork并具有IP地址10.0.0.52”的地方获取IP地址来使其工作。

Then, i go to safari on my device and type in http://10.0.0.52:8000 . 然后,我在设备上转到safari,然后输入http://10.0.0.52:8000 This however, gives me a message about being unable to connect to the server. 但是,这给了我有关无法连接服务器的信息。

I've also tried using the 'name' of my computer (which i grab from System Prefs->Sharing or more simply from the terminal window) and try typing that in on the device's browser like so: http://myMac:8000 That does not work either. 我还尝试使用计算机的“名称”(我从System Prefs-> Sharing或更简单地从终端窗口中获​​取),然后尝试在设备的浏览器中键入该名称,如下所示: http://myMac:8000那也不行。

Any ideas? 有任何想法吗?

Thanks 谢谢

The way I did this was to use Charles Web Proxy, and map a production URL to localHost:8000. 我这样做的方法是使用Charles Web Proxy,并将生产URL映射到localHost:8000。

Charles provides excellent documentation for getting your device up and running for this purpose. Charles为此提供了出色的文档,可用于启动和运行设备。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM