Skip to content

Commit 3aa78b0

Browse files
chrfalchclaude
andcommitted
fix(ios): warn in dev when RCTI18nStrings.bundle cannot be resolved
The resources shipped inside the prebuilt React.framework fail SILENTLY if the framework is ever consumed without being embedded: every localized string falls back to its untranslated default and the privacy manifest drops out of the app's aggregated privacy report, with no build error. Emit a dev-only, once-per-process RCTLogWarn when the bundle resolves nil so an embed regression is observable in every dev console instead of shipping quietly. No behavior change in release (RCT_DEV compiled out) or on the happy path. Not unit-testable (ObjC runtime diagnostics, no jest surface); both RCT_DEV and NDEBUG preprocessing paths compile-verified via clang -fsyntax-only. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 7b29638 commit 3aa78b0

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

packages/react-native/React/I18n/RCTLocalizedString.mm

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#import "RCTLocalizedString.h"
99

10+
#import <React/RCTLog.h>
11+
1012
#if !defined(WITH_FBI18N) || !(WITH_FBI18N)
1113

1214
// Anchors resource lookups to the bundle that contains this code: React.framework
@@ -29,7 +31,19 @@ @implementation RCTI18nStringsAnchor
2931
return [NSBundle bundleWithURL:url];
3032
}
3133
NSString *mainPath = [[NSBundle mainBundle] pathForResource:@"RCTI18nStrings" ofType:@"bundle"];
32-
return mainPath != nil ? [NSBundle bundleWithPath:mainPath] : nil;
34+
if (mainPath != nil) {
35+
return [NSBundle bundleWithPath:mainPath];
36+
}
37+
#if RCT_DEV
38+
// Missing resources are otherwise silent (every lookup falls back to the
39+
// untranslated default and the privacy manifest quietly drops out of the
40+
// app's aggregated privacy report). Called once — the caller caches.
41+
RCTLogWarn(
42+
@"RCTI18nStrings.bundle not found in React.framework or the app bundle. Localized strings will use their "
43+
@"untranslated defaults, and React's PrivacyInfo.xcprivacy may be missing from the app's privacy report. "
44+
@"When consuming the prebuilt React.framework, verify it is embedded into the app with its resources intact.");
45+
#endif
46+
return nil;
3347
}
3448

3549
extern "C" {

0 commit comments

Comments
 (0)