首页 > 解决方案 > Ionic 3 build --prod 仅在 iOS 上导致白屏

问题描述

嗨,我正在尝试将我的 Ionic 3 应用程序编译到 iOS,但它无法正常工作。编译工作正常,但是,当我尝试使用 iOS 模拟器测试应用程序时,我得到了一个白屏。

控制台中没有错误,XCode 错误日志中也没有。

我知道代码没问题,因为它在 android 和浏览器上运行良好。

我已尝试删除并重新安装 iOS 平台,以删除并重新安装该node_module文件夹,但没有成功。

我的猜测是,代码甚至没有加载,因为当我尝试使用 Safari 开发工具检查模拟器时,页面的标题是 index.html 而不是我在登录页面上设置的标题。

以下是相关文件:
我的 config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.mycompany.myAwesomeApp" version="3.0.2" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>my awesome app</name>
<description>My awesome app description</description>
<author email="support@myCompany.com" href="https://myCompany.com">My company dev team</author>
<content src="index.html" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<preference name="ScrollEnabled" value="false" />
<preference name="android-minSdkVersion" value="19" />
<preference name="BackupWebStorage" value="none" />
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="FadeSplashScreenDuration" value="300" />
<preference name="SplashShowOnlyFirstTime" value="false" />
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="3000" />
<preference name="loadUrlTimeoutValue" value="60000" />
<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
<platform name="android">
    <!-- irrelevent android icons -->  
</platform>
<platform name="ios">
    <allow-intent href="itms:*" />
    <allow-intent href="itms-apps:*" />
   <!-- irrelevent icon files -- >
</platform>
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<plugin name="phonegap-plugin-push" spec="~2.2.2" />
<plugin name="cordova-plugin-console" spec="^1.1.0" />
<plugin name="cordova-plugin-device" spec="^1.1.7" />
<plugin name="cordova-plugin-splashscreen" spec="^4.1.0" />
<plugin name="cordova-plugin-statusbar" spec="^2.4.1" />
<plugin name="cordova-plugin-camera" spec="^4.0.2" />
<plugin name="cordova-plugin-geolocation" spec="^4.0.1" />
<plugin name="cordova-plugin-inappbrowser" spec="^2.0.2" />
<plugin name="ionic-plugin-keyboard" spec="^2.2.1" />
<plugin name="cordova-plugin-x-socialsharing" spec="^5.3.2" />
<plugin name="cordova-plugin-headercolor" spec="^1.0.0" />
<plugin name="cordova-plugin-network-information" spec="^2.0.1" />
<plugin name="cordova-plugin-file" spec="^6.0.1" />
<plugin name="cordova-plugin-advanced-http" spec="2.0.4" />
<plugin name="cordova-plugin-ionic-webview" spec="^4.0.1">
    <variable name="ANDROID_SUPPORT_ANNOTATIONS_VERSION" value="27.+" />
</plugin>
<plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
<engine name="android" spec="7.1.4" />
<engine name="browser" spec="5.0.1" />
<engine name="ios" spec="4.5.5" />

离子信息:

Ionic:

    ionic (Ionic CLI)  : 4.12.0 (/Users/nic/.nvm/versions/node/v10.15.3/lib/node_modules/ionic)
    Ionic Framework    : ionic-angular 3.9.0
    @ionic/app-scripts : 3.1.4

Cordova:

    cordova (Cordova CLI) : 9.0.0 (cordova-lib@9.0.1)
    Cordova Platforms     : android 7.1.4, ios 4.5.5
    Cordova Plugins       : cordova-plugin-ionic-webview 1.2.1, (and 16 other plugins)

System:

     NodeJS : v10.15.3 (/Users/nic/.nvm/versions/node/v10.15.3/bin/node)
     npm    : 6.4.1
     OS     : macOS High Sierra
     Xcode  : Xcode 10.0 Build version 10A255 

标签: iostypescriptcordovaionic-framework

解决方案


我最终发现了我的问题。我在构造函数中加载代码,而不是在 ionViewDidLoad 函数中。我不知道为什么这适用于Android,但不适用于iOS。


推荐阅读