【问题标题】:Ionic iOS 10 Issue: Failed to load webpage with error: A server with the specified hostname could not be foundIonic iOS 10 问题:无法加载网页并出现错误:找不到具有指定主机名的服务器
【发布时间】:2019-01-03 13:11:56
【问题描述】:

当我在带有iOS 10 的设备上@9​​87654322@ 时,我遇到了ionic 的这个问题。

这个问题在我使用--livereload时不会发生

iOS 11 的设备不会出现此问题

每次我打开我的应用程序时,它都会向我显示此错误Failed to load webpage with error: A server with the specified hostname could not be found.

xCode 给了我这个错误日志:

2018-07-26 12:47:42.992859 TiTo - Talent in Talent out[25140:1448259] Apache Cordova native platform version 4.5.3 is starting.
2018-07-26 12:47:42.993464 TiTo - Talent in Talent out[25140:1448259] Multi-tasking -> Device: YES, App: YES
2018-07-26 12:47:43.005162 TiTo - Talent in Talent out[25140:1448259] CDVWKWebViewEngine: trying to inject XHR polyfill
2018-07-26 12:47:43.066966 TiTo - Talent in Talent out[25140:1448259] CDVWKWebViewEngine will reload WKWebView if required on resume
2018-07-26 12:47:43.067084 TiTo - Talent in Talent out[25140:1448259] Using Ionic WKWebView
2018-07-26 12:47:43.067705 TiTo - Talent in Talent out[25140:1448259] [CDVTimer][console] 0.093937ms
2018-07-26 12:47:43.067900 TiTo - Talent in Talent out[25140:1448259] [CDVTimer][handleopenurl] 0.102997ms
2018-07-26 12:47:43.070127 TiTo - Talent in Talent out[25140:1448259] Unlimited access to network resources
2018-07-26 12:47:43.070232 TiTo - Talent in Talent out[25140:1448259] [CDVTimer][intentandnavigationfilter] 2.179027ms
2018-07-26 12:47:43.070364 TiTo - Talent in Talent out[25140:1448259] [CDVTimer][gesturehandler] 0.062943ms
2018-07-26 12:47:43.086203 TiTo - Talent in Talent out[25140:1448259] [CDVTimer][splashscreen] 15.730023ms
2018-07-26 12:47:43.086310 TiTo - Talent in Talent out[25140:1448259] CDVIonicKeyboard: resize mode 1
2018-07-26 12:47:43.087343 TiTo - Talent in Talent out[25140:1448259] [CDVTimer][keyboard] 1.037002ms
2018-07-26 12:47:43.087429 TiTo - Talent in Talent out[25140:1448259] [CDVTimer][TotalPluginStartup] 19.853950ms
2018-07-26 12:47:43.601648 TiTo - Talent in Talent out[25140:1448259] Failed to load webpage with error: A server with the specified hostname could not be found.

现在我尝试删除所有插件,只留下默认的ionic start myApp <template_here>。它仍然在 iOS 10 上为我提供了同样的问题

这是我的ionic info 输出:

cli 包:(/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.19.2
ionic (Ionic CLI) : 3.20.0

全局包:

cordova (Cordova CLI) : 8.0.0

本地包:

@ionic/app-scripts : 3.1.10
Cordova Platforms  : ios 4.5.4
Ionic Framework    : ionic-angular 3.9.2

系统:

ios-deploy : 1.9.2
ios-sim    : 6.1.2
Node       : v8.10.0
npm        : 6.1.0
OS         : macOS High Sierra
Xcode      : Xcode 9.4.1 Build version 9F2000

关于为什么会发生这种情况的任何解决方案?

【问题讨论】:

    标签: ios cordova ionic-framework ios10


    【解决方案1】:

    我也有同样的问题。结果发现我的系统在 /etc/hosts 文件中缺少 localhost 的条目。添加修复它。

    这是一个问题的原因是因为 Cordova 不使用 iOS 上的 file:// URL 来加载应用程序的网络视图 - 它使用通过 http://localhost:8080 访问的内置网络服务器。

    【讨论】:

    • 哇,谢谢!经过数小时的激烈谷歌搜索,这是有效的解决方案:) 其他人的提示:模拟器与您的 mac 共享 /etc/hosts 文件,因此只需将以下行添加到您的 mac 的 /etc/hosts 文件:127.0.0.1 localhost
    猜你喜欢
    • 1970-01-01
    • 2018-04-24
    • 2021-05-31
    • 2014-12-06
    • 2018-12-02
    • 2014-03-29
    • 2019-05-05
    • 1970-01-01
    相关资源
    最近更新 更多