diff --git a/Libraries/RCTWebSocketDebugger/RCTWebSocketExecutor.m b/Libraries/RCTWebSocketDebugger/RCTWebSocketExecutor.m index 4d6aba5cc..2f74628c0 100644 --- a/Libraries/RCTWebSocketDebugger/RCTWebSocketExecutor.m +++ b/Libraries/RCTWebSocketDebugger/RCTWebSocketExecutor.m @@ -47,7 +47,7 @@ typedef void (^WSMessageCallback)(NSError *error, NSDictionary *reply); [NSURLConnection connectionWithRequest:[NSURLRequest requestWithURL:startDevToolsURL] delegate:nil]; if (![self connectToProxy]) { - RCTLogError(@"Connection to %@ timed out. Are you running node proxy?", url); + RCTLogError(@"Connection to %@ timed out. Are you running node proxy? If you are running on the device check if you have the right IP address on `RCTWebSocketExecutor.m` file.", url); [self invalidate]; return nil; } diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index 3bf23a5d3..aa2ef7ee9 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -26,7 +26,6 @@ #import "RCTRootView.h" #import "RCTSparseArray.h" #import "RCTUtils.h" -#import "RCTWebViewExecutor.h" /** * Must be kept in sync with `MessageQueue.js`. @@ -530,11 +529,7 @@ static id _latestJSExecutor; - (void)setUp { Class executorClass = _executorClass ?: _globalExecutorClass ?: [RCTContextExecutor class]; - if ([NSStringFromClass(executorClass) isEqualToString:@"RCTWebViewExecutor"]) { - _javaScriptExecutor = [[RCTWebViewExecutor alloc] initWithWebView:[[UIWebView alloc] init]]; - } else { - _javaScriptExecutor = [[executorClass alloc] init]; - } + _javaScriptExecutor = [[executorClass alloc] init]; _latestJSExecutor = _javaScriptExecutor; _eventDispatcher = [[RCTEventDispatcher alloc] initWithBridge:self]; _shadowQueue = dispatch_queue_create("com.facebook.ReactKit.ShadowQueue", DISPATCH_QUEUE_SERIAL); diff --git a/React/Base/RCTDevMenu.m b/React/Base/RCTDevMenu.m index 5fe58f608..f6eee2cd4 100644 --- a/React/Base/RCTDevMenu.m +++ b/React/Base/RCTDevMenu.m @@ -12,6 +12,7 @@ #import "RCTRedBox.h" #import "RCTRootView.h" #import "RCTSourceCode.h" +#import "RCTWebViewExecutor.h" @interface RCTDevMenu () { BOOL _liveReload; @@ -33,13 +34,14 @@ - (void)show { - NSString *debugTitle = self.bridge.executorClass == Nil ? @"Enable Debugging" : @"Disable Debugging"; + NSString *debugTitleChrome = self.bridge.executorClass != Nil && self.bridge.executorClass == NSClassFromString(@"RCTWebSocketExecutor") ? @"Disable Chrome Debugging" : @"Enable Chrome Debugging"; + NSString *debugTitleSafari = self.bridge.executorClass == [RCTWebViewExecutor class] ? @"Disable Safari Debugging" : @"Enable Safari Debugging"; NSString *liveReloadTitle = _liveReload ? @"Disable Live Reload" : @"Enable Live Reload"; UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"React Native: Development" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil - otherButtonTitles:@"Reload", debugTitle, liveReloadTitle, nil]; + otherButtonTitles:@"Reload", debugTitleChrome, debugTitleSafari, liveReloadTitle, nil]; actionSheet.actionSheetStyle = UIBarStyleBlack; [actionSheet showInView:[[[[UIApplication sharedApplication] keyWindow] rootViewController] view]]; } @@ -49,9 +51,14 @@ if (buttonIndex == 0) { [self.bridge reload]; } else if (buttonIndex == 1) { - self.bridge.executorClass = self.bridge.executorClass == Nil ? NSClassFromString(@"RCTWebSocketExecutor") : nil; + Class cls = NSClassFromString(@"RCTWebSocketExecutor"); + self.bridge.executorClass = (self.bridge.executorClass != cls) ? cls : nil; [self.bridge reload]; } else if (buttonIndex == 2) { + Class cls = [RCTWebViewExecutor class]; + self.bridge.executorClass = (self.bridge.executorClass != cls) ? cls : Nil; + [self.bridge reload]; + } else if (buttonIndex == 3) { _liveReload = !_liveReload; [self _pollAndReload]; } diff --git a/React/Executors/RCTWebViewExecutor.m b/React/Executors/RCTWebViewExecutor.m index a31a41a8e..e50fff904 100644 --- a/React/Executors/RCTWebViewExecutor.m +++ b/React/Executors/RCTWebViewExecutor.m @@ -125,6 +125,8 @@ static void RCTReportError(RCTJavaScriptCallback callback, NSString *fmt, ...) RCTAssert(onComplete != nil, @""); _onApplicationScriptLoaded = onComplete; + script = [script stringByReplacingOccurrencesOfString:@"" withString:@""]; if (_objectsToInject.count > 0) { NSMutableString *scriptWithInjections = [[NSMutableString alloc] initWithString:@"/* BEGIN NATIVELY INJECTED OBJECTS */\n"]; [_objectsToInject enumerateKeysAndObjectsUsingBlock:^(NSString *objectName, NSString *blockScript, BOOL *stop) {