-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Implemented automatic IP detection for iOS #8091
Changes from 3 commits
fd5c7c0
0793bb3
9d4902f
ff19d6d
a12038a
8e2a82c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,9 +19,17 @@ | |
static NSString *const kRCTEnableMinificationKey = @"RCT_enableMinification"; | ||
|
||
static NSString *const kDefaultPort = @"8081"; | ||
static NSString *ipGuess; | ||
|
||
@implementation RCTBundleURLProvider | ||
|
||
+ (void)initialize | ||
{ | ||
NSString *ipPath = [[NSBundle mainBundle] pathForResource:@"ip" ofType:@"txt"]; | ||
NSString *ip = [NSString stringWithContentsOfFile:ipPath encoding:NSUTF8StringEncoding error:nil]; | ||
ipGuess = [ip stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]]; | ||
} | ||
|
||
- (NSDictionary *)defaults | ||
{ | ||
static NSDictionary *defaults; | ||
|
@@ -75,8 +83,7 @@ - (BOOL)isPackagerRunning:(NSString *)host | |
|
||
- (NSString *)guessPackagerHost | ||
{ | ||
NSString *host = @"localhost"; | ||
//TODO: Implement automatic IP address detection | ||
NSString *host = ipGuess ? ipGuess : @"localhost"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can shorten this as |
||
if ([self isPackagerRunning:host]) { | ||
return host; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,15 @@ type $NODE_BINARY >/dev/null 2>&1 || nodejs_not_found | |
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) | ||
$PLISTBUDDY -c "Add NSAppTransportSecurity:NSExceptionDomains:localhost:NSTemporaryExceptionAllowsInsecureHTTPLoads bool true" $PLIST | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some questions here:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not completely sure about this, but it doesn't modify the original plist. However, it seems like it only copies the original plist when it is changed. Doing multiple builds, there are some "Entry already exists" messages, but it doesn't signal an error and I think it can be safely ignored. |
||
$PLISTBUDDY -c "Add NSAppTransportSecurity:NSExceptionDomains:$IP.xip.io:NSTemporaryExceptionAllowsInsecureHTTPLoads bool true" $PLIST | ||
echo "$IP.xip.io" > "$DEST/ip.txt" | ||
fi | ||
|
||
$NODE_BINARY "$REACT_NATIVE_DIR/local-cli/cli.js" bundle \ | ||
--entry-file index.ios.js \ | ||
--platform ios \ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you gate this with
RCT_DEV
? We don't want to run this in production.