diff --git a/RealmJS.xcodeproj/xcshareddata/xcschemes/RealmReact.xcscheme b/RealmJS.xcodeproj/xcshareddata/xcschemes/RealmReact.xcscheme index 0ba909fd..8aaeb61c 100644 --- a/RealmJS.xcodeproj/xcshareddata/xcschemes/RealmReact.xcscheme +++ b/RealmJS.xcodeproj/xcshareddata/xcschemes/RealmReact.xcscheme @@ -26,7 +26,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - shouldUseLaunchSchemeArgsEnv = "YES"> + shouldUseLaunchSchemeArgsEnv = "NO"> @@ -53,6 +53,12 @@ ReferencedContainer = "container:RealmJS.xcodeproj"> + + + + diff --git a/tests/ReactTests/ios/ReactTests.xcodeproj/xcshareddata/xcschemes/ReactTestApp.xcscheme b/tests/ReactTests/ios/ReactTests.xcodeproj/xcshareddata/xcschemes/ReactTestApp.xcscheme index d5061232..43f1ec46 100644 --- a/tests/ReactTests/ios/ReactTests.xcodeproj/xcshareddata/xcschemes/ReactTestApp.xcscheme +++ b/tests/ReactTests/ios/ReactTests.xcodeproj/xcshareddata/xcschemes/ReactTestApp.xcscheme @@ -40,7 +40,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - shouldUseLaunchSchemeArgsEnv = "YES"> + shouldUseLaunchSchemeArgsEnv = "NO"> @@ -62,6 +62,12 @@ ReferencedContainer = "container:ReactTests.xcodeproj"> + + + + diff --git a/tests/ReactTests/ios/ReactTests/AppDelegate.m b/tests/ReactTests/ios/ReactTests/AppDelegate.m index bf4e4fc5..b4c5c53a 100644 --- a/tests/ReactTests/ios/ReactTests/AppDelegate.m +++ b/tests/ReactTests/ios/ReactTests/AppDelegate.m @@ -19,8 +19,30 @@ #import "AppDelegate.h" #import "RCTRootView.h" +static NSString * const RealmReactEnableChromeDebuggingKey = @"RealmReactEnableChromeDebugging"; +static NSString * const RCTDevMenuKey = @"RCTDevMenu"; + @implementation AppDelegate +- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + + // Check if this default is explicitly set, otherwise just leave the settings as is. + if ([defaults objectForKey:RealmReactEnableChromeDebuggingKey]) { + NSMutableDictionary *settings = [([defaults dictionaryForKey:RCTDevMenuKey] ?: @{}) mutableCopy]; + NSMutableDictionary *domain = [[defaults volatileDomainForName:NSArgumentDomain] mutableCopy]; + + settings[@"executorClass"] = [defaults boolForKey:RealmReactEnableChromeDebuggingKey] ? @"RCTWebSocketExecutor" : @"RCTContextExecutor"; + domain[RCTDevMenuKey] = settings; + + // Re-register the arguments domain (highest precedent and volatile) with our new overridden settings. + [defaults removeVolatileDomainForName:NSArgumentDomain]; + [defaults setVolatileDomain:domain forName:NSArgumentDomain]; + } + + return YES; +} + - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSURL *jsCodeLocation; diff --git a/tests/ReactTests/ios/ReactTestsTests/RealmReactTests.m b/tests/ReactTests/ios/ReactTestsTests/RealmReactTests.m index 5962ad9f..fb25097d 100644 --- a/tests/ReactTests/ios/ReactTestsTests/RealmReactTests.m +++ b/tests/ReactTests/ios/ReactTestsTests/RealmReactTests.m @@ -26,6 +26,9 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSGlobalContextRef ctx, bool includesNativeCallStack); +@interface RCTDevMenu () +@end + @interface RealmReactTests : RealmJSTests @end @@ -34,12 +37,6 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG @implementation RealmReactTests -+ (void)load { - // Swap the [RCTDevMenu init] method with [NSObject init] in order to disable RCTDevMenu completely. - IMP init = class_getMethodImplementation([NSObject class], @selector(init)); - class_replaceMethod([RCTDevMenu class], @selector(init), init, NULL); -} - + (Class)executorClass { return NSClassFromString(@"RCTContextExecutor"); } @@ -56,14 +53,23 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG } static RCTBridge *s_bridge; + if (!s_bridge) { + [[NSNotificationCenter defaultCenter] postNotificationName:RCTReloadNotification object:nil]; + } + if (!s_bridge.valid) { - NSNotification *notification = [self waitForNotification:RCTJavaScriptDidLoadNotification];; - s_bridge = notification.userInfo[@"bridge"]; + NSNotification *notification = [self waitForNotification:RCTDidCreateNativeModules]; + s_bridge = notification.object; if (!s_bridge) { NSLog(@"No RCTBridge provided by RCTJavaScriptDidLoadNotification"); exit(1); } + + // We don't want the RCTDevMenu from switching the executor class from underneath us. + [s_bridge.devMenu invalidate]; + + [self waitForNotification:RCTJavaScriptDidLoadNotification]; } if (s_bridge.executorClass != executorClass) { @@ -190,6 +196,7 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG @end +/* TODO: Re-enable once this works in CI @implementation RealmReactChromeTests + (Class)executorClass { @@ -201,3 +208,4 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG } @end + */