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

后端 未结 15 2043
南笙
南笙 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:15

    You probably need to sign the app.

    Under the Project navigator, click on your app. Then select your target from the project and targets list. Within the "General" tab, find the 'Signing' section. You'll need to specify a team here.

    See this link for more info: https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/LaunchingYourApponDevices/LaunchingYourApponDevices.html#//apple_ref/doc/uid/TP40012582-CH27-SW4

    0 讨论(0)
  • 2021-02-01 02:15

    Just experienced this and after an hour of debugging realized I had recently enabled my systems firewall and set it to "Block all incoming connections".

    Weird thing is that android was functioning fine on a physical device, however iOS on a physical device was not able to connect to the RN server. Relaxed the firewall rules and now iOS can connect to the RN server.

    0 讨论(0)
  • 2021-02-01 02:17

    It should be perfectly possible to run the app in debug, on the device, without the packager attached! You have to use react-native bundle to create an offline bundle, and add it to your Xcode project. Then your app should fall back to that bundle when the packager is not available.

    This used to be in the Deploying to Device FB docs, not sure why it's not there anymore.

    Sample call (our index.ios.js is placed in ./dist by TypeScript):

    react-native bundle --dev true --assets-dest ./ios --entry-file ./dist/index.ios.js --platform ios --bundle-output ios/main.jsbundle
    

    Also, it's apparently necessary to tell your app to run directly from the bundle rather than try to access the development server, which seems to cause the timeout (we had the same issue as OP).

    Comment out this line:

    jsCodeLocation = // whatever
    

    And add this line:

    jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
    
    0 讨论(0)
提交回复
热议问题