简体   繁体   English

Release 模式下的 Ionic 应用程序显示白屏

[英]Ionic app in Release mode shows white screen

When I try to run my Ionic 4 app in release mode (both in Simulator and a local iOS device) the splash screen comes up and then all I get is a white screen.当我尝试以发布模式(在模拟器和本地 iOS 设备中)运行我的 Ionic 4 应用程序时,启动画面出现,然后我得到的只是一个白屏。

For example, when I execute this command:例如,当我执行此命令时:

ionic cordova run ios --release --prod -- --verbose

I also tried a brand new 'myApp' project ( https://ionicframework.com/docs/installation/cli ) and exactly the same thing happens.我还尝试了一个全新的“myApp”项目( https://ionicframework.com/docs/installation/cli )并且发生了完全相同的事情。 There is no error even when I add verbose and consolelogs.即使我添加详细和控制台日志也没有错误。

In debug mode, a local server is started and that renders the app.在调试模式下,启动本地服务器并呈现应用程序。 How is it supposed to work in release mode?它应该如何在发布模式下工作?

Update: I installed the browser platform since I can't inspect an iOS device in Chrome and I see this error in the browser console which I'll now investigate:更新:我安装了浏览器平台,因为我无法在 Chrome 中检查 iOS 设备,我在浏览器控制台中看到了这个错误,我现在将调查:

Error: Cannot find module '@angular/core'

The main issue was that I somehow referenced some things from 'ionic-angular' instead of '@ionic/angular'.主要问题是我以某种方式从“ionic-angular”而不是“@ionic/angular”中引用了一些东西。 I don't know how that happened or why it didn't cause issues in Debug mode.我不知道这是怎么发生的,也不知道为什么它在调试模式下没有引起问题。

There was also a node-sass issue that I had to resolve first.还有一个 node-sass 问题,我必须先解决。 Once I did that, I got some helpful errors running npm test .一旦我这样做了,我在运行npm test遇到了一些有用的错误。

rm -rf node_modules 
sudo rm -rf /tmp/* 
rm -rf /root/.npm/node-sass 
npm uninstall --save node-sass 
npm cache clean --force
npm install

config.xml config.xml

 <preference name="auto-hide-splash-screen" value="false" /> 
 <preference name="AutoHideSplashScreen" value="false" />

main.js please change main.js请更改

this.platform.ready().then(function () {
        _this.statusBar.styleDefault();
        _this.splashScreen.hide();
    });

to

this.platform.ready().then(function () {
            _this.statusBar.styleDefault();
            setTimeout(function(){
                _this.splashScreen.hide();

            }, 3000);
        });

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

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