Removed debug code from release builds

This commit is contained in:
Nick Lockwood
2015-04-21 09:48:29 -07:00
parent 25ae5485da
commit ee898c24c7
17 changed files with 226 additions and 121 deletions

View File

@@ -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

View File

@@ -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 @{