React native app stuck on splash screen on device but works in simulator

后端 未结 15 2085
南笙
南笙 2021-02-01 01:27

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

15条回答
  •  后悔当初
    2021-02-01 02:10

    This issue could raise due to the following possibilities:

    1. Your run schema set to release instead of debug, so always expect to load main.jsbundle, instead of running from the debug server. Change it by Product->Schema-> Edit Schema->Run-> Build Configuration: Debug

    Check on Xcode log that any message like NSURLConnection finished with error - code -1004 or NSURLConnection finished with error - code -1022. Go to Project->Target->Build Phases-> + -> New Run Script Phase

    1. (-1004) You have configured your XCode project from sketch and forgot to enter the react-native xcode script on Build Phases:

    For the below version of React Native 50: export NODE_BINARY=node ../node_modules/react-native/packager/react-native-xcode.sh

    For the higher version of React Native 50: export NODE_BINARY=node ../node_modules/react-native/scripts/react-native-xcode.sh

    1. (-1022) Your app ATS issue, check on Info.plist, and you can turn off ATS using below code: NSAppTransportSecurity NSAllowsArbitraryLoads

提交回复
热议问题