Do not access to main bundle when running in prod (#51043)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51043

The call to the mainBundle to read the `RCTLegacyWarningsEnabled` key can sometime deadlock in prod.
However, these are development logs that we don't want to run in Prod.

This change should disable the logs in prod, skipping the access to the `mainBundle`, and avoid the deadlock completely.

## Changelog:
[Internal] - Fix deadlock at startup to read `RCTLegacyWarningsEnabled`

Reviewed By: philIip, javache

Differential Revision: D73987454

fbshipit-source-id: 014410266733fdfa1e7b29d41fab5f7112b1ddb4
This commit is contained in:
Riccardo Cipolleschi authored and Facebook GitHub Bot committed 2025-05-01 04:48:55 -07:00
1 parent 773ba66c64
commit e1d2285791
1 file changed
+4
@@ -49,9 +49,13 @@ void RCTSetNewArchEnabled(BOOL enabled)
BOOL RCTAreLegacyLogsEnabled(void)
{
#if RCT_DEBUG
NSNumber *rctNewArchEnabled =
(NSNumber *)[[NSBundle mainBundle] objectForInfoDictionaryKey:@"RCTLegacyWarningsEnabled"];
return rctNewArchEnabled.boolValue;
#else
return NO;
#endif
}
static NSString *__nullable _RCTJSONStringifyNoRetry(id __nullable jsonObject, NSError **error)