diff --git a/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj b/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj index 348d04f0d..cf9440c05 100644 --- a/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj +++ b/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj @@ -632,6 +632,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)"; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, diff --git a/Examples/UIExplorer/UIExplorer.xcodeproj/xcshareddata/xcschemes/UIExplorer.xcscheme b/Examples/UIExplorer/UIExplorer.xcodeproj/xcshareddata/xcschemes/UIExplorer.xcscheme index b231b77ee..488c0077d 100644 --- a/Examples/UIExplorer/UIExplorer.xcodeproj/xcshareddata/xcschemes/UIExplorer.xcscheme +++ b/Examples/UIExplorer/UIExplorer.xcodeproj/xcshareddata/xcschemes/UIExplorer.xcscheme @@ -1,6 +1,6 @@ 0 && ![testModule isDone] && error == nil) { @@ -98,13 +95,6 @@ } else { RCTAssert([testModule isDone], @"Test didn't finish within %d seconds", TIMEOUT_SECONDS); } - -#else - - expectErrorBlock(@"RCTRedBox unavailable. Set RCT_DEBUG=1 for testing."); - -#endif - } @end diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index 5b6a92682..5dd3bac5a 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -934,8 +934,6 @@ static id _latestJSExecutor; _loading = NO; if (error != nil) { -#if RCT_DEBUG // Red box is only available in debug mode - NSArray *stack = [[error userInfo] objectForKey:@"stack"]; if (stack) { [[RCTRedBox sharedInstance] showErrorMessage:[error localizedDescription] @@ -945,8 +943,6 @@ static id _latestJSExecutor; withDetails:[error localizedFailureReason]]; } -#endif - } else { [[NSNotificationCenter defaultCenter] postNotificationName:RCTJavaScriptDidLoadNotification @@ -980,33 +976,6 @@ static id _latestJSExecutor; action:^(UIKeyCommand *command) { [weakSelf reload]; }]; - // reset to normal mode - [commands registerKeyCommandWithInput:@"n" - modifierFlags:UIKeyModifierCommand - action:^(UIKeyCommand *command) { - __strong RCTBridge *strongSelf = weakSelf; - strongSelf.executorClass = Nil; - [strongSelf reload]; - }]; - -#if RCT_DEV // Debug executors are only available in dev mode - - // reload in debug mode - [commands registerKeyCommandWithInput:@"d" - modifierFlags:UIKeyModifierCommand - action:^(UIKeyCommand *command) { - __strong RCTBridge *strongSelf = weakSelf; - strongSelf.executorClass = NSClassFromString(@"RCTWebSocketExecutor"); - if (!strongSelf.executorClass) { - strongSelf.executorClass = NSClassFromString(@"RCTWebViewExecutor"); - } - if (!strongSelf.executorClass) { - RCTLogError(@"WebSocket debugger is not available. " - "Did you forget to include RCTWebSocketExecutor?"); - } - [strongSelf reload]; - }]; -#endif #endif } @@ -1091,7 +1060,7 @@ static id _latestJSExecutor; [self _invokeAndProcessModule:@"BatchedBridge" method:@"callFunctionReturnFlushedQueue" - arguments:@[moduleID, methodID, args ?: @[]] + arguments:@[moduleID ?: @0, methodID ?: @0, args ?: @[]] context:RCTGetExecutorID(_javaScriptExecutor)]; } diff --git a/React/Base/RCTDevMenu.h b/React/Base/RCTDevMenu.h index 8057e5708..537675576 100644 --- a/React/Base/RCTDevMenu.h +++ b/React/Base/RCTDevMenu.h @@ -16,10 +16,10 @@ /** * Developer menu, useful for exposing extra functionality when debugging. */ -@interface RCTDevMenu : NSObject +@interface RCTDevMenu : NSObject /** - * Is the menu enabled. The menu is enabled by default in debug mode, but + * Is the menu enabled. The menu is enabled by default if RCT_DEV=1, but * you may wish to disable it so that you can provide your own shake handler. */ @property (nonatomic, assign) BOOL shakeToShow; @@ -41,7 +41,7 @@ @property (nonatomic, assign) NSTimeInterval liveReloadPeriod; /** - * Manually show the menu. This will. + * Manually show the dev menu. */ - (void)show; diff --git a/React/Base/RCTDevMenu.m b/React/Base/RCTDevMenu.m index 4af9d4e62..529840e0a 100644 --- a/React/Base/RCTDevMenu.m +++ b/React/Base/RCTDevMenu.m @@ -10,12 +10,16 @@ #import "RCTDevMenu.h" #import "RCTBridge.h" +#import "RCTDefines.h" +#import "RCTKeyCommands.h" #import "RCTLog.h" #import "RCTProfile.h" #import "RCTRootView.h" #import "RCTSourceCode.h" #import "RCTUtils.h" +#if RCT_DEV + @interface RCTBridge (Profiling) - (void)startProfiling; @@ -36,7 +40,7 @@ static NSString *const RCTShowDevMenuNotification = @"RCTShowDevMenuNotification @end -@interface RCTDevMenu () +@interface RCTDevMenu () @end @@ -68,6 +72,28 @@ RCT_EXPORT_MODULE() selector:@selector(showOnShake) name:RCTShowDevMenuNotification object:nil]; + +#if TARGET_IPHONE_SIMULATOR + + __weak RCTDevMenu *weakSelf = self; + RCTKeyCommands *commands = [RCTKeyCommands sharedInstance]; + + // Workaround around the first cmd+D not working: http://openradar.appspot.com/19613391 + // You can register just the cmd key and do nothing. This will trigger the bug and cmd+R + // will work like a charm! + [commands registerKeyCommandWithInput:@"" + modifierFlags:UIKeyModifierCommand + action:NULL]; + + // reload in debug mode + [commands registerKeyCommandWithInput:@"d" + modifierFlags:UIKeyModifierCommand + action:^(UIKeyCommand *command) { + __strong RCTDevMenu *strongSelf = weakSelf; + [strongSelf show]; + }]; +#endif + } return self; } @@ -104,6 +130,7 @@ RCT_EXPORT_MODULE() actionSheet.actionSheetStyle = UIBarStyleBlack; [actionSheet showInView:[UIApplication sharedApplication].keyWindow.rootViewController.view]; + _actionSheet = actionSheet; } - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex @@ -218,6 +245,16 @@ RCT_EXPORT_MODULE() @end +#else // Unvailable + +@implementation RCTDevMenu + +- (void)show {} + +@end + +#endif + @implementation RCTBridge (RCTDevMenu) - (RCTDevMenu *)devMenu diff --git a/React/Base/RCTRedBox.h b/React/Base/RCTRedBox.h index 058759da7..9a3a9b49a 100644 --- a/React/Base/RCTRedBox.h +++ b/React/Base/RCTRedBox.h @@ -7,10 +7,6 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#import "RCTDefines.h" - -#if RCT_DEBUG // Red box is only available in debug mode - #import @interface RCTRedBox : NSObject @@ -27,5 +23,3 @@ - (void)dismiss; @end - -#endif diff --git a/React/Base/RCTRedBox.m b/React/Base/RCTRedBox.m index 626840252..b54d18aa3 100644 --- a/React/Base/RCTRedBox.m +++ b/React/Base/RCTRedBox.m @@ -7,15 +7,14 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#import "RCTDefines.h" - -#if RCT_DEBUG // Red box is only available in debug mode - #import "RCTRedBox.h" #import "RCTBridge.h" +#import "RCTDefines.h" #import "RCTUtils.h" +#if RCT_DEBUG + @interface RCTRedBoxWindow : UIWindow @property (nonatomic, copy) NSString *lastErrorMessage; @@ -310,4 +309,19 @@ @end +#else // Disabled + +@implementation RCTRedBox + ++ (instancetype)sharedInstance { return nil; } +- (void)showErrorMessage:(NSString *)message {} +- (void)showErrorMessage:(NSString *)message withDetails:(NSString *)details {} +- (void)showErrorMessage:(NSString *)message withStack:(NSArray *)stack {} +- (void)updateErrorMessage:(NSString *)message withStack:(NSArray *)stack {} +- (void)showErrorMessage:(NSString *)message withStack:(NSArray *)stack showIfHidden:(BOOL)shouldShow {} +- (NSString *)currentErrorMessage { return nil; } +- (void)dismiss {} + +@end + #endif diff --git a/React/Modules/RCTExceptionsManager.m b/React/Modules/RCTExceptionsManager.m index 878138282..f391e6af0 100644 --- a/React/Modules/RCTExceptionsManager.m +++ b/React/Modules/RCTExceptionsManager.m @@ -61,12 +61,8 @@ RCT_EXPORT_METHOD(reportUnhandledException:(NSString *)message } else { - // Filter out numbers so the same base errors are mapped to the same categories independent of incorrect values. - NSString *pattern = @"[+-]?\\d+[,.]?\\d*"; - NSString *sanitizedMessage = [message stringByReplacingOccurrencesOfString:pattern withString:@"" options:NSRegularExpressionSearch range:(NSRange){0, message.length}]; - - if (sanitizedMessage.length > maxMessageLength) { - sanitizedMessage = [[sanitizedMessage substringToIndex:maxMessageLength] stringByAppendingString:@"..."]; + if (message.length > maxMessageLength) { + message = [[message substringToIndex:maxMessageLength] stringByAppendingString:@"..."]; } NSMutableString *prettyStack = [NSMutableString stringWithString:@"\n"]; @@ -74,7 +70,7 @@ RCT_EXPORT_METHOD(reportUnhandledException:(NSString *)message [prettyStack appendFormat:@"%@@%@:%@\n", frame[@"methodName"], frame[@"lineNumber"], frame[@"column"]]; } - NSString *name = [@"Unhandled JS Exception: " stringByAppendingString:sanitizedMessage]; + NSString *name = [@"Unhandled JS Exception: " stringByAppendingString:message]; [NSException raise:name format:@"Message: %@, stack: %@", message, prettyStack]; } diff --git a/React/React.xcodeproj/project.pbxproj b/React/React.xcodeproj/project.pbxproj index 10867e9cb..c415cb87a 100644 --- a/React/React.xcodeproj/project.pbxproj +++ b/React/React.xcodeproj/project.pbxproj @@ -582,8 +582,9 @@ GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", + "RCT_DEBUG=1", + "RCT_DEV=1", + "RCT_NSASSERT=1", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -621,6 +622,7 @@ ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_PREPROCESSOR_DEFINITIONS = ""; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; @@ -638,10 +640,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_STATIC_ANALYZER_MODE = deep; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); + GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)"; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; HEADER_SEARCH_PATHS = ( "$(inherited)", @@ -658,6 +657,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_STATIC_ANALYZER_MODE = deep; + GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)"; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; HEADER_SEARCH_PATHS = ( "$(inherited)",