简体   繁体   English

Xcode错误:无法启动[目录] - 主机字符串无效:'localhost'

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

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: 在“Build Succeeded”之后我收到以下错误:

error: failed to launch '/Users/dimitrisagagiotis/Library/Developer/Xcode/DerivedData/test-guvgymeaqzlsheascqbmllxdtpsn/Build/Products/Debug/test' -- invalid host string: 'localhost' 错误:无法启动'/ Users / dimitrisagagiotis / Library / Developer / Xcode / DerivedData / test-guvgymeaqzlsheascqbmllxdtpsn / Build / Products / Debug / test' - 无效的主机字符串:'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 您必须验证/etc/hosts文件中是否包含以下行
 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost 
  • Execute dscacheutil -flushcache to reload the DNS configuration 执行dscacheutil -flushcache以重新加载DNS配置

I have absolutely no idea how it was possible to get a host file without the loopback DNS entries to localhost. 我完全不知道如何在没有环回DNS条目的情况下获取主机文件到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. 从这个角度来看, “无效主机字符​​串:'localhost'”非常自我描述:localhost是系统的无效主机字符​​串,它根本无法解析localhost。

Xcode error Invalid string localhost Xcode错误无效的字符串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 然后按control-o然后按enter键,然后按control-x

//then type //然后输入

  dscacheutil -flushcache 

//use Xcode for c & c++ without internet ! //在没有互联网的情况下使用Xcode进行c&c ++!

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. 除了检查hosts文件中的正确行是否检查行结尾是“Unix”而不是其他类型的行结尾。 This solved the problem for me. 这解决了我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM