-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A Bug in Reloading JS Bundle since react-native@0.29 #9617
Comments
I use v0.32 (macOSX on an actual iPad) and I only have these 4 options on the Developer Menu (when shaking the iPad): Reload Why can't I see the "Hot reload" and "Live Reload" options? |
The same issue happened to me with RN 0.33 (and 0.32) and only on iOS device. On android and ios simulator it works. The reload action doesn't work on an iOS device. It doesn't even make the request to the packager, it only gets the pre-bundle like @richarddlu explained. I even tried to kill the packager before running like @richarddlu suggested, but the problem persisted. And the "Hot reload" and "Live Reload" options disappeared like @af7 said. A similar issue was closed but without a solution for this case: #8461 I finally found the problem in my case and a workaround: The script that runs on "Bundle React native code and images" build phase is: It gets the ip of the machine with (en0 is ethernet): IP=$(ipconfig getifaddr en0) But i'm using wifi in mac and in my case like is explained in: http://apple.stackexchange.com/questions/20547/how-do-i-find-my-ip-address-from-the-command-line Only this command returns the IP address (en1 is wireless): IP=$(ipconfig getifaddr en1) So i created a separate file react-native-fix-ip-xcode.sh with the following code: set -x
DEST=$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH
if [[ "$CONFIGURATION" = "Debug" && "$PLATFORM_NAME" != "iphonesimulator" ]]; then
PLISTBUDDY='/usr/libexec/PlistBuddy'
PLIST=$TARGET_BUILD_DIR/$INFOPLIST_PATH
IP=$(ipconfig getifaddr en0)
if [ -z "$IP" ]; then
IP=$(ipconfig getifaddr en1)
fi
$PLISTBUDDY -c "Add NSAppTransportSecurity:NSExceptionDomains:localhost:NSTemporaryExceptionAllowsInsecureHTTPLoads bool true" "$PLIST"
$PLISTBUDDY -c "Add NSAppTransportSecurity:NSExceptionDomains:$IP.xip.io:NSTemporaryExceptionAllowsInsecureHTTPLoads bool true" "$PLIST"
echo "$IP.xip.io" > "$DEST/ip.txt"
fi And added ../react-native-fix-ip-xcode.sh after ../node_modules/react-native/packager/react-native-xcode.sh on the same Build Phase. And it worked! :) @satya164 Do you think the above code in "react-native-fix-ip-xcode.sh" is a valid pull request to "react-native-xcode.sh". So it also find the IP on en1 (wireless)? |
I'll let someone with more experience with Code answer that. cc @Kureev |
Hey everybody! First of all, let's try to summarize a bunch of problems you experience:
Now, let's try to address these issues:
Please, let me know if this feedback makes any sense to you or you know the way to improve it ❤️ |
… device Find your mac's IP Address in en1 (wireless) if it doesn't find it in en0 (wired/ethernet) when react native xcode's script runs on iOS device
Thanks @Kureev your feedback definitely helped! :D This issue didn't happen to me: Pre-bundling doesn't work if there is an existing instance of packager running. It never worked even when i killed the existing instance of packager. I agree with you that if it uses a pre-bundled version, it shouldn't have a hot module replacement / live reload options. In case of the IP detection i believe this PR will fix the issue: #9964 Because the IP address should be in either en0 or en1 depending on how you access the internet. |
… device Find your mac's IP Address in en1 (wireless) if it doesn't find it in en0 (wired/ethernet) when react native xcode's script runs on iOS device
… device Find your mac's IP Address in en1 (wireless) if it doesn't find it in en0 (wired/ethernet) when react native xcode's script runs on iOS device
… device Find your mac's IP Address in en1 (wireless) if it doesn't find it in en0 (wired/ethernet) when react native xcode's script runs on iOS device
… device Find your mac's IP Address in en1 (wireless) if it doesn't find it in en0 (wired/ethernet) when react native xcode's script runs on iOS device
… device Find your mac's IP Address in en1 (wireless) if it doesn't find it in en0 (wired/ethernet) when react native xcode's script runs on iOS device
When this will be pushed to a stable release? |
Summary: React native's reload javascript option doesn't always work on iOS devices since version 0.29, as described in facebook/react-native#9617 It only doesn't work when you have a mac on a wireless connection, because react-native-xcode.sh can't find your IP address correctly in this case and will just fallback to use the pre-bundling option on your app. This small change in react-native-xcode.sh fixed this issue for our project and should fix this issue for all mac users that use wireless connection and that will run a debug version of the app on a real iOS device. Closes facebook/react-native#9964 Differential Revision: D3923035 fbshipit-source-id: 436cfa2103e10221270034233552ce34720505d3
A very nice improvement of React Native since version 0.29 is using
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
to switch using packager server with DEBUG mode or pre-bundle with RELEASE mode in an actual device.
However it does not work when the packager server is already running when building the IOS product.
I guess the reason is caused by that the program decides to still use the pre-bundle when it fails to start a packager server since the 8081 port is already taken by another running packager server.
A workaround is to stopping the running packager server before building. But the bug still needs to be fixed since it causes a lot confusion.
The text was updated successfully, but these errors were encountered: