I am trying to run in command line tool the following code:
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
// insert code here...
NSLog(@"Hello, World!");
}
return 0;
}
and after "Build Succeeded" I am getting the following error:
error: failed to launch '/Users/dimitrisagagiotis/Library/Developer/Xcode/DerivedData/test-guvgymeaqzlsheascqbmllxdtpsn/Build/Products/Debug/test' -- invalid host string: 'localhost'
any solution??? Thank you
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.
来源:https://stackoverflow.com/questions/9832234/xcode-error-failed-to-launch-directory-invalid-host-string-localhost