Skip to content

Commit 68aab49

Browse files
riteshshukla04meta-codesync[bot]
authored andcommitted
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`. <img width="567" height="112" alt="image" src="https://github.com/user-attachments/assets/7a8e8cf4-a8a3-42d3-a65f-9943cbf296f2" /> ### 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 . <img width="548" height="59" alt="image" src="https://github.com/user-attachments/assets/b6d9fb7a-00df-4bf2-aa0c-c61fb3a6538f" /> 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 <img width="633" height="155" alt="image" src="https://github.com/user-attachments/assets/7eb811cc-d1ba-410d-902c-4217bfc47b40" /> 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: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [IOS][FIXED] - Fix glog namespace issue to allow using interop mode of objcxx Pull Request resolved: #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
1 parent 0cda10b commit 68aab49

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

packages/react-native/scripts/ios-configure-glog.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,21 @@ cp -f src/glog/logging.h "$EXPORTED_INCLUDE_DIR/"
102102
cp -f src/glog/raw_logging.h "$EXPORTED_INCLUDE_DIR/"
103103
cp -f src/glog/stl_logging.h "$EXPORTED_INCLUDE_DIR/"
104104
cp -f src/glog/vlog_is_on.h "$EXPORTED_INCLUDE_DIR/"
105+
106+
107+
# Create a custom module.modulemap that works with Swift C++ interop
108+
# The issue is that glog headers include other headers inside namespace blocks
109+
# which Clang treats as module imports inside namespaces (which is illegal)
110+
# Solution: Use textual headers to prevent submodule creation
111+
cat > src/glog/module.modulemap << 'MODULEMAP'
112+
module glog {
113+
// Use textual headers to avoid submodule generation
114+
// This prevents the "import within namespace" error with Swift C++ interop
115+
textual header "log_severity.h"
116+
textual header "logging.h"
117+
textual header "raw_logging.h"
118+
textual header "stl_logging.h"
119+
textual header "vlog_is_on.h"
120+
export *
121+
}
122+
MODULEMAP

packages/react-native/third-party-podspecs/glog.podspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Pod::Spec.new do |spec|
3333
spec.exclude_files = "src/windows/**/*"
3434
spec.compiler_flags = '-Wno-shorten-64-to-32'
3535
spec.resource_bundles = {'glog_privacy' => 'glog/PrivacyInfo.xcprivacy'}
36+
spec.module_map = 'src/glog/module.modulemap'
3637

3738
spec.pod_target_xcconfig = {
3839
"USE_HEADERMAP" => "NO",

0 commit comments

Comments
 (0)