Bar*_*amo 33 xcode cordova ionic-framework ios8
在更新到Xcode 6和iOS 8后,我遇到了Ionic项目的问题.
尝试运行项目时,我在Xcode中收到以下错误:
Failed to load webpage with error: Could not connect to the server.
Run Code Online (Sandbox Code Playgroud)
完整的日志是:
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.
Run Code Online (Sandbox Code Playgroud)
即使在尝试更新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>
Run Code Online (Sandbox Code Playgroud)
和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) {
}])
;
Run Code Online (Sandbox Code Playgroud)
tob*_*ika 87
我有同样的问题.
我通过Xcode打开了平台文件夹中的ios项目,但是我忘记了Xcode文件夹中的代码库不是最新的,因此被破坏了.
要在Xcode项目中获取新代码,请使用以下命令:
ionic cordova prepare ios
Run Code Online (Sandbox Code Playgroud)
如果您的问题与我的问题根源相同,这应该会有所帮助.
Lau*_*ens 14
当我尝试在 iOS 设备上运行我的 Ionic 4 应用程序时,我遇到了这个问题。
为我解决的问题是使用该--address选项在所有网络接口上运行开发服务器,例如:
ionic cordova run ios --address=0.0.0.0 --debug --consolelogs -l
如果在模拟器上使用实时调试后使用Xcode打开项目,则也可能发生此错误
离子科尔多瓦模拟ios --livereload -lc
要解决此问题,请关闭Xcode并使用再次构建项目
ionic cordova build ios
Run Code Online (Sandbox Code Playgroud)
然后使用Xcode构建并运行。