Xcode error: failed to launch [directory] — invalid host string: 'localhost'

一曲冷凌霜 提交于 2019-12-01 18:55:06

I had the same issue and resolved it with the following steps.

  • You have to verify that the following lines are included in the /etc/hosts file
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost 
fe80::1%lo0     localhost
  • Execute dscacheutil -flushcache to reload the DNS configuration

I have absolutely no idea how it was possible to get a host file without the loopback DNS entries to localhost. From this point of view, "invalid host string: 'localhost'" is pretty self-describing: localhost is a invalid host string to the system, it simply can not resolve localhost.

Xcode error Invalid string localhost

open terminal

//type

sudo nano /etc/hosts

// it may ask for password , enter the password;

// copy and paste this

127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost 
fe80::1%lo0     localhost

then press control-o and then press enter and then press control-x

//then type

  dscacheutil -flushcache 

//use Xcode for c & c++ without internet !

In addition to checking that the correct lines are in the hosts file check that line endings are "Unix" and not some other kind of line ending. This solved the problem for me.

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