iPhone HTTP server works on simulator but not on iPhone device

风格不统一 提交于 2020-01-15 11:36:14

问题


I want to embed a webserver in an iPhone app so as to download files from application's document directory. I am using iPhone Http Server.

Everything works fine on iPhone simulator. Even I am able to get files using http://: or localhost:.

But on device I am not able to connect. Safari says: "Cannot open page". Even http://iphone.local: doest not work on same device as app is installed.

Please suggest.


回答1:


Your app goes into background, doesn't it? I think you use Mac's Safari when you try your app in iOS Simulator. And when you try it on iPhone, your app is in background and iPhone's Safari is foreground.

If so, I believe the following helps you:

cocoaHTTPServer doesn't work in background. Try keep your app foreground and access it from other machine.

And, there is no way to maintain server functionality all the time... https://devforums.apple.com/message/706241



来源:https://stackoverflow.com/questions/12245051/iphone-http-server-works-on-simulator-but-not-on-iphone-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!