XCode 6 Simulator ignores hosts file changes

前端 未结 2 1373
旧时难觅i
旧时难觅i 2020-12-31 12:16

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.

I

相关标签:
2条回答
  • 2020-12-31 13:02

    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
    

    My story:

    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.

    0 讨论(0)
  • 2020-12-31 13:06

    Have you tried flushing the DNS cache with the command

    sudo dscacheutil -flushcache
    

    before quitting and relaunching the iOS Simulator ?

    0 讨论(0)
提交回复
热议问题