From e5908b4175d73a0c3caa4299595f76a21e2bc6a1 Mon Sep 17 00:00:00 2001 From: Christian Falch Date: Fri, 17 Jul 2026 09:57:22 +0200 Subject: [PATCH] fix(iOS): opt spm_dependency pod targets out of Swift explicit modules A pod target consuming an SPM binary target via spm_dependency sees the binary target's module.modulemap twice: Xcode processes the xcframework into both the platform-wide products dir and the pod's TARGET_BUILD_DIR, and the existing SWIFT_INCLUDE_PATHS workaround makes the former visible. Implicit modules tolerate the duplicate definition; the explicit-modules dependency scanner (the default starting with Xcode 26) fails with "redefinition of module". Before the VFS-overlay removal these targets carried -ivfsoverlay, which disqualified them from explicit modules and masked the problem; the overlay's removal made them eligible and the nightly-tests react-native-enriched-markdown (RaTeX) job went red. Set SWIFT_ENABLE_EXPLICIT_MODULES=NO on exactly the targets spm_dependency touches, restoring the previous compile mode for the CocoaPods+SPM interop path only. Co-Authored-By: Claude Opus 4.8 --- packages/react-native/scripts/cocoapods/spm.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/react-native/scripts/cocoapods/spm.rb b/packages/react-native/scripts/cocoapods/spm.rb index baa2a04ee9d0..23a73f4eaa54 100644 --- a/packages/react-native/scripts/cocoapods/spm.rb +++ b/packages/react-native/scripts/cocoapods/spm.rb @@ -37,6 +37,14 @@ def apply_on_post_install(installer) unless target.build_settings(config.name)['SWIFT_INCLUDE_PATHS'].include?(search_path) target.build_settings(config.name)['SWIFT_INCLUDE_PATHS'].push(search_path) end + # The search path above makes the platform-wide products dir visible + # to this target, so an SPM binary target's module.modulemap is seen + # twice: once there and once in the target's own build dir (Xcode + # processes the xcframework into both). Implicit modules tolerate the + # duplicate, but the explicit-modules dependency scanner (the default + # starting with Xcode 26) fails with "redefinition of module". Opt + # SPM-consuming pod targets out of explicit modules. + target.build_settings(config.name)['SWIFT_ENABLE_EXPLICIT_MODULES'] = 'NO' end end end