How to enable Live Reload in iOS Device running React Native app?

拜拜、爱过 提交于 2019-11-30 16:46:00

问题


I'm trying to enable Live Reload mode, but there is no such item in Dev Menu:


回答1:


You have this problem is mainly because your device and your development machine is not in the same LAN. check if it is. Make sure your computer and your device connected in the save LAN, everything will be ok.

After all ur devices connected to the same LAN. And if u are using Xcode.

  1. Close the React Native packager (or just close the terminal window)
  2. Delete the app in your iOS device
  3. Clean Xcode project.
  4. Run command npm start -- reset-cache

Then everything will be OK.




回答2:


You need to edit the source for jsCodeLocation from your AppDelegate.

The main problem that the

jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

is looking for localhost by default, in simulator it will work as simulator and pc are on the same machine, but for device localhost will be different so to make it work, you need to change that line to

jsCodeLocation = [NSURL URLWithString:@"http://192.168.1.16:8081/index.ios.bundle?platform=ios&dev=true&minify=false&hot=true"];

here 192.168.1.16 change it to your PC local IP address




回答3:


If u are using IOS Simulator, follow the menu Hardware > Shake Gesture, and click the Enable Live Reload option.

Hope it helps! :)




回答4:


If you are running the app on your actual native device. Then shake the device and it will pop up the me menu.




回答5:


If you are running the simulator, make sure you sure you "Connect Hardware Keyboard"



来源:https://stackoverflow.com/questions/38772373/how-to-enable-live-reload-in-ios-device-running-react-native-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!