diff --git a/React/Base/RCTBatchedBridge.m b/React/Base/RCTBatchedBridge.m index 15ba6caec..1a9e9d299 100644 --- a/React/Base/RCTBatchedBridge.m +++ b/React/Base/RCTBatchedBridge.m @@ -190,13 +190,20 @@ RCT_EXTERN NSArray *RCTGetModuleClasses(void); // Force JS __DEV__ value to match RCT_DEBUG if (shouldOverrideDev) { NSString *sourceString = [[NSString alloc] initWithData:source encoding:NSUTF8StringEncoding]; - NSRange range = [sourceString rangeOfString:@"__DEV__="]; + NSRange range = [sourceString rangeOfString:@"\\b__DEV__\\s*?=\\s*?(!1|!0|false|true)" + options:NSRegularExpressionSearch]; + RCTAssert(range.location != NSNotFound, @"It looks like the implementation" "of __DEV__ has changed. Update -[RCTBatchedBridge loadSource:]."); - NSRange valueRange = {range.location + range.length, 2}; - if ([[sourceString substringWithRange:valueRange] isEqualToString:@"!1"]) { - source = [[sourceString stringByReplacingCharactersInRange:valueRange withString:@" 1"] dataUsingEncoding:NSUTF8StringEncoding]; + + NSString *valueString = [sourceString substringWithRange:range]; + if ([valueString rangeOfString:@"!1"].length) { + valueString = [valueString stringByReplacingOccurrencesOfString:@"!1" withString:@"!0"]; + } else if ([valueString rangeOfString:@"false"].length) { + valueString = [valueString stringByReplacingOccurrencesOfString:@"false" withString:@"true"]; } + source = [[sourceString stringByReplacingCharactersInRange:range withString:valueString] + dataUsingEncoding:NSUTF8StringEncoding]; } _onSourceLoad(error, source);