React本机应用程序停留在设备的初始屏幕上,但可在模拟器中使用 [英] React native app stuck on splash screen on device but works in simulator

查看:180
本文介绍了React本机应用程序停留在设备的初始屏幕上,但可在模拟器中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的React Native应用程序可以在XCode模拟器中正常运行,但是当我在物理设备上运行时,我的iPhone出现了问题.该应用程序启动并卡在React Native初始屏幕上,在10-15秒后该应用程序崩溃/关闭.这是什么原因造成的,我该如何预防?

My React Native app works in the XCode simulator with no issues, but when I run in a physical device, my iPhone, there's a problem. The app launches and gets stuck on the React Native splash screen, the after 10-15 seconds the app crashes/closes. What's the cause of this and how can I prevent it?

推荐答案

似乎我已经找到了问题.根据 https://facebook.github.io/react-native/docs /running-on-device ,当您在设备上构建并运行该应用程序时,您的应用程序将从计算机上的打包程序中加载js文件,以便您可以实时重新加载应用程序.这意味着您的设备必须连接到计算机或与计算机处于同一wifi网络中.如果您的设备无法访问打包程序,它将停留在初始屏幕上并退出.

It seems that I have found the problem. According to https://facebook.github.io/react-native/docs/running-on-device, when you build and run the app on your device, your app will load js files from the packager on your computer, so you can live reload your app. That means your device has to be connected to your computer or has to be in the same wifi network as your computer. If your device can't access the packager, it will stuck on the splash screen and quit.

要在设备上可靠运行,请编辑构建架构和构建发行版.

To run on your device reliably, edit build schema and build release version.

这篇关于React本机应用程序停留在设备的初始屏幕上,但可在模拟器中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆