mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Removed debug code from release builds
This commit is contained in:
@@ -44,10 +44,11 @@ RCT_EXPORT_METHOD(reportUnhandledException:(NSString *)message
|
||||
return;
|
||||
}
|
||||
|
||||
if (RCT_DEBUG) {
|
||||
[[RCTRedBox sharedInstance] showErrorMessage:message withStack:stack];
|
||||
return;
|
||||
}
|
||||
#if RCT_DEBUG // Red box is only available in debug mode
|
||||
|
||||
[[RCTRedBox sharedInstance] showErrorMessage:message withStack:stack];
|
||||
|
||||
#else
|
||||
|
||||
static NSUInteger reloadRetries = 0;
|
||||
const NSUInteger maxMessageLength = 75;
|
||||
@@ -76,14 +77,21 @@ RCT_EXPORT_METHOD(reportUnhandledException:(NSString *)message
|
||||
NSString *name = [@"Unhandled JS Exception: " stringByAppendingString:sanitizedMessage];
|
||||
[NSException raise:name format:@"Message: %@, stack: %@", message, prettyStack];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(updateExceptionMessage:(NSString *)message
|
||||
stack:(NSArray *)stack)
|
||||
{
|
||||
if (RCT_DEBUG) {
|
||||
|
||||
#if RCT_DEBUG // Red box is only available in debug mode
|
||||
|
||||
[[RCTRedBox sharedInstance] updateErrorMessage:message withStack:stack];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -222,6 +222,7 @@ static NSString *RCTViewNameForModuleName(NSString *moduleName)
|
||||
return name;
|
||||
}
|
||||
|
||||
// TODO: only send name once instead of a dictionary of name and type keyed by name
|
||||
static NSDictionary *RCTViewConfigForModule(Class managerClass, NSString *viewName)
|
||||
{
|
||||
NSMutableDictionary *nativeProps = [[NSMutableDictionary alloc] init];
|
||||
@@ -234,8 +235,13 @@ static NSDictionary *RCTViewConfigForModule(Class managerClass, NSString *viewNa
|
||||
SEL getInfo = method_getName(method);
|
||||
const char *selName = sel_getName(getInfo);
|
||||
if (strlen(selName) > prefixLength && strncmp(selName, prefix, prefixLength) == 0) {
|
||||
NSDictionary *info = ((NSDictionary *(*)(id, SEL))method_getImplementation(method))(managerClass, getInfo);
|
||||
nativeProps[info[@"name"]] = info;
|
||||
NSString *name = @(selName);
|
||||
NSRange nameRange = [name rangeOfString:@"_"];
|
||||
if (nameRange.length) {
|
||||
name = [name substringFromIndex:nameRange.location + 1];
|
||||
NSString *type = ((NSString *(*)(id, SEL))method_getImplementation(method))(managerClass, getInfo);
|
||||
nativeProps[name] = @{@"name": name, @"type": type};
|
||||
}
|
||||
}
|
||||
}
|
||||
return @{
|
||||
|
||||
Reference in New Issue
Block a user