From 68aab492e116a60daf33bc3992196b510a497100 Mon Sep 17 00:00:00 2001 From: riteshshukla04 Date: Mon, 12 Jan 2026 09:43:57 -0800 Subject: [PATCH] feat:- fix compilation issue with objcxx interop (#55117) Summary: So currently RN app is broken with following error if the `SWIFT_OBJC_INTEROP_MODE` is changed to `objcxx`. image ### Why do we need this interop ? So currently any pod that uses `objcxx` as interop (For example Any library created with Nitro modules) cannot be imported into App directly . image We are using this in a nitro module where we override bundle url . And nitro-player for jellify app where we create a new scene for carplay . Currently we are using hacky stuffs like creating two pods to address this but the solution is messy. ### RCA for failing image Currently glog imports some things inside namespace which is not allowed. ### Fix This patches creates a module map that uses textual headers to prevent submodule creation. We can still keep using the old interop by default . Users who need to do this can change the interop themselves bypass-github-export-checks ## Changelog: [IOS][FIXED] - Fix glog namespace issue to allow using interop mode of objcxx Pull Request resolved: https://github.com/facebook/react-native/pull/55117 Test Plan: To test this I forked Nightly repo and ran against all the libraries and nothing seems to fail With objcxx interop :- https://github.com/riteshshukla04/nightly-tests/actions/runs/20908210967 with Objc interop :- https://github.com/riteshshukla04/nightly-tests/actions/runs/20902452877 Reviewed By: cortinico Differential Revision: D90503097 Pulled By: cipolleschi fbshipit-source-id: c1b46e901ec1515998428e1f3ca46f9d48d17bd3 --- .../react-native/scripts/ios-configure-glog.sh | 18 ++++++++++++++++++ .../third-party-podspecs/glog.podspec | 1 + 2 files changed, 19 insertions(+) diff --git a/packages/react-native/scripts/ios-configure-glog.sh b/packages/react-native/scripts/ios-configure-glog.sh index 6571abb68cf..b8d759c7171 100755 --- a/packages/react-native/scripts/ios-configure-glog.sh +++ b/packages/react-native/scripts/ios-configure-glog.sh @@ -102,3 +102,21 @@ cp -f src/glog/logging.h "$EXPORTED_INCLUDE_DIR/" cp -f src/glog/raw_logging.h "$EXPORTED_INCLUDE_DIR/" cp -f src/glog/stl_logging.h "$EXPORTED_INCLUDE_DIR/" cp -f src/glog/vlog_is_on.h "$EXPORTED_INCLUDE_DIR/" + + +# Create a custom module.modulemap that works with Swift C++ interop +# The issue is that glog headers include other headers inside namespace blocks +# which Clang treats as module imports inside namespaces (which is illegal) +# Solution: Use textual headers to prevent submodule creation +cat > src/glog/module.modulemap << 'MODULEMAP' +module glog { + // Use textual headers to avoid submodule generation + // This prevents the "import within namespace" error with Swift C++ interop + textual header "log_severity.h" + textual header "logging.h" + textual header "raw_logging.h" + textual header "stl_logging.h" + textual header "vlog_is_on.h" + export * +} +MODULEMAP diff --git a/packages/react-native/third-party-podspecs/glog.podspec b/packages/react-native/third-party-podspecs/glog.podspec index af7668077f9..e4eb90d1e77 100644 --- a/packages/react-native/third-party-podspecs/glog.podspec +++ b/packages/react-native/third-party-podspecs/glog.podspec @@ -33,6 +33,7 @@ Pod::Spec.new do |spec| spec.exclude_files = "src/windows/**/*" spec.compiler_flags = '-Wno-shorten-64-to-32' spec.resource_bundles = {'glog_privacy' => 'glog/PrivacyInfo.xcprivacy'} + spec.module_map = 'src/glog/module.modulemap' spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO",