XCode 6 Simulator忽略主机文件更改 [英] XCode 6 Simulator ignores hosts file changes

查看:262
本文介绍了XCode 6 Simulator忽略主机文件更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个客户端 - 服务器应用程序,为了使用模拟器测试它我在虚拟机上有一个服务器,我更改了mac的主机文件(/ etc / hosts),所以我可以到达那里。

I have a client-server App, in order to test it with Simulator I have a server on a virtual machine and I change mac's hosts file (/etc/hosts) so I can get there.

它在XCode 5中工作正常,但在XCode 6上无法访问服务器。
尝试打开NSURLConnection时,我得到 -

It works fine in XCode 5, but on XCode 6 the server cannot be reached. When trying to open an NSURLConnection to it I get -


错误域= kCFErrorDomainCFNetwork代码= 310沟通时出现问题使用安全的Web代理服务器(HTTPS)。
UserInfo = 0x78b3fc50 {_kCFStreamErrorCodeKey = -2096,

NSErrorFailingURLStringKey = https:/ /xxx.yyy.zzz/mobile/login
NSErrorFailingURLKey = https:// xxx.yyy.zzz / mobile / login
NSLocalizedDescription =与安全Web代理服务器通信时出现问题
(HTTPS)。,_ kCFStreamErrorDomainKey = 4,NSLocalizedRecoverySuggestion =请检查您的
代理设置。有关此问题的帮助,请与系统管理员联系。

Error Domain=kCFErrorDomainCFNetwork Code=310 "There was a problem communicating with the secure web proxy server (HTTPS)." UserInfo=0x78b3fc50 {_kCFStreamErrorCodeKey=-2096,
NSErrorFailingURLStringKey=https://xxx.yyy.zzz/mobile/login, NSErrorFailingURLKey=https://xxx.yyy.zzz/mobile/login, NSLocalizedDescription=There was a problem communicating with the secure web proxy server (HTTPS)., _kCFStreamErrorDomainKey=4, NSLocalizedRecoverySuggestion=Please check your proxy settings. For help with this problem, contact your system administrator.

当然可以通过输入 https://xxx.yyy.zzz ,它回答了ping,如果我打开XCode 5,它仍然有效。

Of course the server can be reached from Safari by typing https://xxx.yyy.zzz, it answers to ping and it still works if I turn on XCode 5.

我认为模拟器忽略了mac的hosts文件的更改,或者它可能使用它自己的私有主机文件。

I figure that the Simulator ignores the changes for the mac's hosts file, or maybe it uses it's own private hosts file.

如果我输入一些硬编码解析(在代码中将xxx.yyy.zzz翻译成它的IP地址)可以到达服务器。

If I enter some "hard coded resolving" (translating in the code the xxx.yyy.zzz to it's ip address) the server can be reached.

任何人都知道如何解决这个问题?

Anyone has any idea how to solve this?

推荐答案

解决方案:



确保添加每个主机别名在不同的行:

Solution:

Make sure you add each host alias on different line:

# Wrong!
  127.0.0.1 example.com www.example.com

# Good
  127.0.0.1 example.com
  127.0.0.1 www.example.com



我的故事:



我遇到了同样的问题Xcode 6。

My story:

I had the same issue with Xcode 6.

OSX中与 / etc / hosts 相关的错误或行为更改。

There is a bug or behaviour change in OSX related to /etc/hosts.

如果我在OSX的 / etc / hosts 文件中的同一行添加更多主机别名,iOS模拟器会给我同样的错误。
但是如果我在它自己的行上添加每个主机别名,iOS模拟器就像我期望的那样工作。

If I add more host aliases on the same line in OSX's /etc/hosts file, iOS simulator gives me the same error. But if I add each host alias on it's own line, iOS simulator works as I expect it to.

这篇关于XCode 6 Simulator忽略主机文件更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆