在更新到Xcode6和iOS 8后,我遇到了离子项目的问题。
当尝试运行项目时,我在Xcode中得到以下错误:
Failed to load webpage with error: Could not connect to the server.
完整日志为:
2014-10-11 14:08:29.468 test[23293:109668] Apache Cordova native platform version 3.6.3 is starting.
2014-10-11 14:08:29.469 test[23293:109668] Multi-tasking -> Device: YES, App: YES
2014-10-11 14:08:29.495 test[23293:109668] Unlimited access to network resources
2014-10-11 14:08:29.866 test[23293:109668] [CDVTimer][keyboard] 0.079989ms
2014-10-11 14:08:29.866 test[23293:109668] [CDVTimer][TotalPluginStartup] 0.284970ms
2014-10-11 14:08:30.721 test[23293:109668] Resetting plugins due to page load.
2014-10-11 14:08:30.764 test[23293:109668] Failed to load webpage with error: Could not connect to the server.
即使在尝试更新Ionic和Cordova并开始一个新项目时,这个错误也会不断出现。
我找不到任何有这个特殊错误的线程,我不确定这是iOS 8的兼容性问题还是我的设置搞砸了。
谢谢!
编辑:
有关index.html和app.js中内容的更多信息
index.html:
<!DOCTYPE html>
<html ng-app="app" ng-controller="AppCtrl">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<!-- compiled CSS -->
<link rel="stylesheet" type="text/css" href="assets/app-0.0.1.css" />
<!-- compiled JavaScript -->
<script type="text/javascript" src="src/app/app.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
</head>
<body >
<ion-nav-view></ion-nav-view>
<!-- Load deferred scripts -->
<!-- Google Maps -->
<script src='http://maps.googleapis.com/maps/api/js?sensor=true&callback=googleMapsLoaded' defer async></script>
</body>
</html>
和app.js (在使用ngbp编译其余文件之前):
angular.module( 'app', [
'ionic',
// Common requirements
'templates-app',
'templates-common',
// Common Components
'app.auth',
// All page modules
'app.businesses',
'app.business',
'app.search',
'app.branch',
'app.profile',
'app.feed',
// Other dependencies
'ui.router'
])
.config(['$stateProvider', '$urlRouterProvider', function myAppConfig ($stateProvider, $urlRouterProvider) {
$stateProvider
.state('app', {
url: "/app",
abstract: true,
templateUrl: "menu/menu.tpl.html",
controller: 'AppCtrl'
});
$urlRouterProvider.otherwise( 'app/feed' );
}])
.run(['$ionicPlatform', 'appAuthService', '$sessionStorage', function($ionicPlatform, appAuthService, $sessionStorage) {
// Initialize ionic styles
$ionicPlatform.ready(function() {
if(window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
StatusBar.styleLightContent();
}
});
// Initialize app authentication service
appAuthService.init();
// Initialize a session cache validation object
$sessionStorage.updated = {};
}])
.controller( 'AppCtrl', ['$scope', '$location', function AppCtrl ($scope, $location) {
}])
;
发布于 2014-11-27 00:47:10
我也有同样的问题。
我通过Xcode打开了platform文件夹中的ios项目,但我忘记了Xcode文件夹中的代码库不是最新的,因此损坏了。
要获得Xcode项目中的新代码,请使用以下命令:
ionic cordova prepare ios
如果你的问题和我的一样,这应该会有帮助。
发布于 2019-07-27 21:26:03
当我试图在iOS设备上运行我的Ionic 4应用程序时,我遇到了这个问题。
对我来说,解决这个问题的方法是使用--address
选项在所有网络接口上运行开发服务器,例如:
ionic cordova run ios --address=0.0.0.0 --debug --consolelogs -l
发布于 2018-04-11 00:35:54
我在使用XCode9.3和ionic3时也遇到了同样的问题。事实证明,这个问题是由于WKWebview正常工作所需的"config.xml“中缺少配置而导致的。在删除"platforms/ ios“文件夹并再次运行”ios build ios --prod“之前,我在config.xml中添加了以下代码片段。
<allow-navigation href="http://localhost:8080/*" />
<feature name="CDVWKWebViewEngine">
<param name="ios-package" value="CDVWKWebViewEngine" />
</feature>
<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
有关ionic团队的更详细解释,请参阅link here。
https://stackoverflow.com/questions/26314005
复制相似问题