diff --git a/packages/react-native/React/Base/RCTUtils.mm b/packages/react-native/React/Base/RCTUtils.mm index d1ac5cefae3..7d7eba0e55f 100644 --- a/packages/react-native/React/Base/RCTUtils.mm +++ b/packages/react-native/React/Base/RCTUtils.mm @@ -59,7 +59,7 @@ BOOL RCTAreLegacyLogsEnabled(void) dispatch_once(&onceToken, ^{ NSNumber *rctNewArchEnabled = (NSNumber *)[[NSBundle mainBundle] objectForInfoDictionaryKey:@"RCTLegacyWarningsEnabled"]; - _legacyWarningEnabled = rctNewArchEnabled == nil || rctNewArchEnabled.boolValue; + _legacyWarningEnabled = rctNewArchEnabled.boolValue; }); return _legacyWarningEnabled; } diff --git a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm index bf07abd5a02..df8e878ae26 100644 --- a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm +++ b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm @@ -517,14 +517,19 @@ void RCTInstanceSetRuntimeDiagnosticFlags(NSString *flags) // Set up hot module reloading in Dev only. [strongSelf->_performanceLogger markStopForTag:RCTPLScriptDownload]; [devSettings setupHMRClientWithBundleURL:sourceURL]; - +#if RCT_DEV [strongSelf _logOldArchitectureWarnings]; +#endif }]; } - (void)_logOldArchitectureWarnings { - NSMutableArray *modulesInOldArchMode = getModulesLoadedWithOldArch(); + if (!RCTAreLegacyLogsEnabled()) { + return; + } + + NSArray *modulesInOldArchMode = [getModulesLoadedWithOldArch() copy]; if (modulesInOldArchMode.count > 0) { NSMutableString *moduleList = [NSMutableString new]; for (NSString *moduleName in modulesInOldArchMode) { @@ -533,7 +538,6 @@ void RCTInstanceSetRuntimeDiagnosticFlags(NSString *flags) RCTLogWarn( @"The following modules have been registered using a RCT_EXPORT_MODULE. That's a Legacy Architecture API. Please migrate to the new approach as described in the https://reactnative.dev/docs/next/turbo-native-modules-introduction#register-the-native-module-in-your-app website or open a PR in the library repository:\n%@", moduleList); - [modulesInOldArchMode removeAllObjects]; } }