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.
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 -
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.
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.
I figure that the Simulator ignores the changes for the mac's hosts file, or maybe it uses it's own private hosts file.
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?
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
I had the same issue with Xcode 6.
There is a bug or behaviour change in OSX related to /etc/hosts
.
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.
Have you tried flushing the DNS cache with the command
sudo dscacheutil -flushcache
before quitting and relaunching the iOS Simulator ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With