From 9fcfd91ef1b7b152276d9df99113a70d234dd135 Mon Sep 17 00:00:00 2001 From: Jay Garcia Date: Wed, 8 Apr 2015 15:25:23 -0400 Subject: [PATCH 1/2] Attempt to enable debugging upon launch of the application --- Examples/UIExplorer/UIExplorer/AppDelegate.m | 1 + Libraries/RCTTest/RCTTestRunner.m | 1 + React/Base/RCTBridge.h | 1 + React/Base/RCTBridge.m | 6 ++++++ React/Base/RCTRootView.h | 6 ++++++ React/Base/RCTRootView.m | 2 ++ 6 files changed, 17 insertions(+) diff --git a/Examples/UIExplorer/UIExplorer/AppDelegate.m b/Examples/UIExplorer/UIExplorer/AppDelegate.m index 84734f12f9d642..287085e2d708a5 100644 --- a/Examples/UIExplorer/UIExplorer/AppDelegate.m +++ b/Examples/UIExplorer/UIExplorer/AppDelegate.m @@ -42,6 +42,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( // jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation + withDebugEnabled:NO // YES to enable debugging upon app launch moduleName:@"UIExplorerApp" launchOptions:launchOptions]; diff --git a/Libraries/RCTTest/RCTTestRunner.m b/Libraries/RCTTest/RCTTestRunner.m index 8cb5169c37a1be..9d16ca496d9288 100644 --- a/Libraries/RCTTest/RCTTestRunner.m +++ b/Libraries/RCTTest/RCTTestRunner.m @@ -67,6 +67,7 @@ - (void)runTest:(SEL)test module:(NSString *)moduleName initialProps:(NSDictiona RCTTestModule *testModule = [[RCTTestModule alloc] initWithSnapshotController:_snapshotController view:nil]; testModule.testSelector = test; RCTBridge *bridge = [[RCTBridge alloc] initWithBundlePath:_script + withDebugEnabled:NO moduleProvider:^(){ return @[testModule]; } diff --git a/React/Base/RCTBridge.h b/React/Base/RCTBridge.h index 3f0ad735ec0988..74e6ba7824d3c6 100644 --- a/React/Base/RCTBridge.h +++ b/React/Base/RCTBridge.h @@ -49,6 +49,7 @@ extern NSString *RCTBridgeModuleNameForClass(Class bridgeModuleClass); * parameters or configuration. */ - (instancetype)initWithBundlePath:(NSString *)bundlepath + withDebugEnabled:(BOOL)debugEnabled moduleProvider:(RCTBridgeModuleProviderBlock)block launchOptions:(NSDictionary *)launchOptions NS_DESIGNATED_INITIALIZER; diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index 3bf23a5d351aff..e1605d4f62aada 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -514,6 +514,7 @@ @implementation RCTBridge static id _latestJSExecutor; - (instancetype)initWithBundlePath:(NSString *)bundlePath + withDebugEnabled:(BOOL)debugEnabled moduleProvider:(RCTBridgeModuleProviderBlock)block launchOptions:(NSDictionary *)launchOptions { @@ -521,6 +522,11 @@ - (instancetype)initWithBundlePath:(NSString *)bundlePath _bundlePath = bundlePath; _moduleProvider = block; _launchOptions = launchOptions; +#if DEBUG + if (debugEnabled == YES) { + self.executorClass = NSClassFromString(@"RCTWebSocketExecutor"); + } +#endif [self setUp]; [self bindKeys]; } diff --git a/React/Base/RCTRootView.h b/React/Base/RCTRootView.h index f85bb7ecb965de..71e4890d2c4a51 100644 --- a/React/Base/RCTRootView.h +++ b/React/Base/RCTRootView.h @@ -31,6 +31,7 @@ extern NSString *const RCTReloadViewsNotification; * to all the instances. */ - (instancetype)initWithBundleURL:(NSURL *)bundleURL + withDebugEnabled:(BOOL)debugginEnable moduleName:(NSString *)moduleName launchOptions:(NSDictionary *)launchOptions; @@ -73,6 +74,11 @@ extern NSString *const RCTReloadViewsNotification; - (void)reload; + (void)reloadAll; +/** + * Method to allow programmatic debug enable upon boot of the application + */ +- (void)toggleDebug; + @property (nonatomic, weak) UIViewController *backingViewController; @property (nonatomic, strong, readonly) UIView *contentView; diff --git a/React/Base/RCTRootView.m b/React/Base/RCTRootView.m index 6c15e509cd1d7a..026c17ac423b26 100644 --- a/React/Base/RCTRootView.m +++ b/React/Base/RCTRootView.m @@ -74,10 +74,12 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge } - (instancetype)initWithBundleURL:(NSURL *)bundleURL + withDebugEnabled:(BOOL)debugEnabled moduleName:(NSString *)moduleName launchOptions:(NSDictionary *)launchOptions { RCTBridge *bridge = [[RCTBridge alloc] initWithBundlePath:bundleURL.absoluteString + withDebugEnabled:debugEnabled moduleProvider:nil launchOptions:launchOptions]; return [self initWithBridge:bridge From 1369b5bd046ac662de0226ea4abe0d2889b245d3 Mon Sep 17 00:00:00 2001 From: Jay Garcia Date: Wed, 8 Apr 2015 15:46:45 -0400 Subject: [PATCH 2/2] Removed toggleDebug method from RCTRootView.h --- React/Base/RCTRootView.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/React/Base/RCTRootView.h b/React/Base/RCTRootView.h index 71e4890d2c4a51..54d24c8d4df626 100644 --- a/React/Base/RCTRootView.h +++ b/React/Base/RCTRootView.h @@ -74,11 +74,6 @@ extern NSString *const RCTReloadViewsNotification; - (void)reload; + (void)reloadAll; -/** - * Method to allow programmatic debug enable upon boot of the application - */ -- (void)toggleDebug; - @property (nonatomic, weak) UIViewController *backingViewController; @property (nonatomic, strong, readonly) UIView *contentView;