From 09d357c0df0c901304ca2d44de3c32f351c2005e Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Tue, 13 Jun 2023 08:06:24 -0700 Subject: [PATCH] Fix undefined symbols `_FBcoreLocalexxHash48` and `_RCTLocalizedStringFromKey` in OSS (#37838) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37838 We see a linker failure in the OSS build because our header exports C-style functions (not ObjC), that Objective C will assume are C ABI, but we build them as C++ functions. Internally these are all marked as `extern "C"`, so to not deviate I did the same here to expose these always as plain C functions. Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D46671506 fbshipit-source-id: 5b3005074303763d55801c4d24ac9250b96d45ba --- packages/react-native/React/I18n/RCTLocalizedString.h | 8 ++++++++ packages/react-native/React/I18n/RCTLocalizedString.mm | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/packages/react-native/React/I18n/RCTLocalizedString.h b/packages/react-native/React/I18n/RCTLocalizedString.h index a190fccdab2..68c48bd6775 100644 --- a/packages/react-native/React/I18n/RCTLocalizedString.h +++ b/packages/react-native/React/I18n/RCTLocalizedString.h @@ -14,6 +14,10 @@ #import +#ifdef __cplusplus +extern "C" { +#endif + uint64_t FBcoreLocalexxHash48(const char *input, uint64_t length, uint64_t seed); NSString *RCTLocalizedStringFromKey(uint64_t key, NSString *defaultValue); @@ -23,4 +27,8 @@ NSString *RCTLocalizedStringFromKey(uint64_t key, NSString *defaultValue); #define RCTLocalizedString(string, description) \ RCTLocalizedStringFromKey(RCTLocalizedStringKey(string, description), @"" string) +#ifdef __cplusplus +} +#endif + #endif diff --git a/packages/react-native/React/I18n/RCTLocalizedString.mm b/packages/react-native/React/I18n/RCTLocalizedString.mm index ae2e05dd276..6a09613b77a 100644 --- a/packages/react-native/React/I18n/RCTLocalizedString.mm +++ b/packages/react-native/React/I18n/RCTLocalizedString.mm @@ -9,6 +9,8 @@ #if !defined(WITH_FBI18N) || !(WITH_FBI18N) +extern "C" { + static NSString *FBTStringByConvertingIntegerToBase64(uint64_t number) { const NSUInteger base = 64; @@ -39,4 +41,6 @@ NSString *RCTLocalizedStringFromKey(uint64_t key, NSString *defaultValue) return [bundle localizedStringForKey:FBTStringByConvertingIntegerToBase64(key) value:defaultValue table:nil]; } } +} + #endif