Uh oh!
There was an error while loading. Please reload this page.
Automatically configure local IP address for iOS device development - #6362
Automatically configure local IP address for iOS device development#6362aleclarson wants to merge 1 commit into
Conversation
facebook-github-bot
commented
Mar 8, 2016
By analyzing the blame information on this pull request, we identified @foghina, @nicklockwood and @javache to be potential reviewers. |
facebook-github-bot
commented
Mar 8, 2016
@aleclarson updated the pull request. |
facebook-github-bot
commented
Mar 8, 2016
@aleclarson updated the pull request. |
facebook-github-bot
commented
Mar 8, 2016
@aleclarson updated the pull request. |
javache
commented
Mar 8, 2016
I'm not a huge fan of doing this automatically, as at some point, it will be very confusing where this IP is coming from, the wrong IP will be used, or people won't find the magic shell scripts embedded in the xcode project. |
Kureev
commented
Mar 8, 2016
@aleclarson looks nice 👍 |
aleclarson
commented
Mar 8, 2016
|
Kureev
commented
Mar 8, 2016
I think it should be something like an optional parameter: |
aleclarson
commented
Mar 8, 2016
@Kureev Ooh I really like that. We could also take advantage of |
facebook-github-bot
commented
Mar 8, 2016
@aleclarson updated the pull request. |
facebook-github-bot
commented
Mar 8, 2016
@aleclarson updated the pull request. |
aleclarson
commented
Mar 8, 2016
The recent changes include:
Changes still needed:
|
There was a problem hiding this comment.
This depends strongly on your system (only macbooks on wifi, right?). And if you assume that you're on a mac, you could just use ipconfig getifaddr en0
There was a problem hiding this comment.
@mroswald I just copied that line from a commit linked by this comment. This has also been discussed in depth in #4245. It can't be ipconfig getifaddr en0 because you might change networks often (eg: you go to a coffee shop, or you use ethernet at work). I doubt what I have is the perfect solution; but as long as there is a way to override the automatic IP, we can use the current solution. If anyone finds a way to make it more robust, just submit a PR.
There was a problem hiding this comment.
I still don't fully understand what happens when you have, say, en0 and en1? Does it pick the random one?
There was a problem hiding this comment.
Sorry, I haven't tested that scenario. Maybe @christopherdro knows.
There was a problem hiding this comment.
@frantic has a good point that this might not work for all cases.
I believe new macs that are only wireless use en0 however, older macs that use en0 when wired in and en1 for wifi.
There was a problem hiding this comment.
ipconfig getifaddr en0 is less magical and will be easier to fix in the future. If we want to go the more complex route, we can use ifconfig command to find and store all available interfaces, and somehow offer the user to choose from the list. I don't think it's worth it at this point.
frantic
commented
Mar 10, 2016
Slightly different approach for addressing the same problem: #6345 I guess the main difference is that in #6345 we store the IP address in a file inside the main app's bundle, but here we modify a header file. I guess both have pro's and con's. In Facebook's case we have a copy of RN inside the repo, which means every Xcode build will change the header with the IP and might cause troubles. Using a text file is nice when we consider a potential use case of downloading pre-built binaries (instead of compiling the shell ourselves), in which case it's much easier to swap the IP. I like that @javache good point, but I think it's worth it. Now basically everyone has to mess with the IP setting every time they want to test on device. We can solve the 80%-case and have clearer error messages on how to deal with the rest 20%. |
facebook-github-bot
commented
Mar 13, 2016
@aleclarson updated the pull request. |
2 similar comments
facebook-github-bot
commented
Mar 14, 2016
@aleclarson updated the pull request. |
facebook-github-bot
commented
Mar 14, 2016
@aleclarson updated the pull request. |
aleclarson
commented
Mar 14, 2016
Weird. I haven't updated the pull request in 6 days, but the bot keeps saying I'm updating it. 😯 |
facebook-github-bot
commented
Apr 16, 2016
@aleclarson updated the pull request. |
facebook-github-bot
commented
Apr 16, 2016
@aleclarson updated the pull request. |
ghost
commented
Apr 17, 2016
@foghina would you mind taking a look at this pull request? It's been a while since the last commit was reviewed. |
christopherdro
commented
Apr 17, 2016
Sorry for the late response. This is what I've been using internally for the last couple months and has been serving us well. Then update your AppDelegate.m. #import"RCTIPAddress.h"
#if RCT_DEV
#if TARGET_OS_SIMULATOR
jsCodeLocation = [NSURLURLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios"];
#elseNSString *URLString = [NSStringstringWithFormat:@"http://%@:8081/index.ios.bundle?platform=ios", LOCAL_IP_ADDRESS ];
jsCodeLocation = [NSURLURLWithString:URLString];
#endif
#else
jsCodeLocation = [[NSBundlemainBundle] URLForResource:@"main"withExtension:@"jsbundle"];
#endif |
rauchy
commented
May 17, 2016
ghost
commented
May 28, 2016
@aleclarson do you have any updates for this pull request? It's been a while since the last update so wanted to check in and see if you've looked at the requested changes. |
ghost
commented
May 28, 2016
@aleclarson updated the pull request. |
aleclarson
commented
May 28, 2016
I noticed - (NSURL *)packagerURL
{
NSString *host = [_bridge.bundleURL host];
if (!host) {
returnnil;
}
NSString *scheme = [_bridge.bundleURL scheme];
NSNumber *port = [_bridge.bundleURL port];
if (!port) {
port = @8081; // Packager default port
}
return [NSURLURLWithString:[NSStringstringWithFormat:@"%@://%@:%@/message?role=shell", scheme, host, port]];
}If Otherwise, we can just replace that code with |
facebook-github-bot
commented
May 28, 2016
@aleclarson updated the pull request. |
javache
commented
May 28, 2016
Hi @aleclarson, @nathanajah is working on open-sourcing our internal component that provides automatic packager discovery and will incorporate your changes. Thank you for your work on this PR! |
aleclarson
commented
May 28, 2016
@javache Sounds good! |
isaaclem
commented
Sep 13, 2018
Is there any recommended way to handle on running ios devices? |
Fixes#6291, #4351, #4245, #1597, and #883.
It's worth mentioning that I did not change the call to
/statusbecause it's in a "Run Script" phase. Any ideas on fixing that as well?