From a93e82f0db576a2202bbb25fe3fcc9c985ffc8a6 Mon Sep 17 00:00:00 2001 From: Leandro Piccione Date: Wed, 26 Aug 2026 13:06:29 +0200 Subject: [PATCH] fix(xcframework): namespace public headers to avoid include/module.modulemap collision MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ship the module map under Headers/CNemoTextProcessing/ instead of at the top level of each slice. Xcode's ProcessXCFramework copies every xcframework's Headers/ into the shared $BUILT_PRODUCTS_DIR/include, so two artifacts that both ship a top-level module.modulemap claim the same output path and the build fails before compiling anything. The directory is named after the MODULE (CNemoTextProcessing), not the xcframework, because that is the subdirectory Clang searches when resolving a module — naming it after the xcframework yields 'no such module'. swift build does not use ProcessXCFramework, which is why CI never saw this. --- build-xcframework.sh | 7 +++++++ swift/include/{ => CNemoTextProcessing}/module.modulemap | 0 .../{ => CNemoTextProcessing}/nemo_text_processing.h | 0 3 files changed, 7 insertions(+) rename swift/include/{ => CNemoTextProcessing}/module.modulemap (100%) rename swift/include/{ => CNemoTextProcessing}/nemo_text_processing.h (100%) diff --git a/build-xcframework.sh b/build-xcframework.sh index 2307674..94f47c7 100755 --- a/build-xcframework.sh +++ b/build-xcframework.sh @@ -31,6 +31,13 @@ lipo -create \ -output "$BUILD_DIR/macos/libtext_processing_rs.a" echo "Creating XCFramework..." +# NOTE: headers live in swift/include/CNemoTextProcessing/ so each slice gets +# Headers/CNemoTextProcessing/module.modulemap. Xcode's ProcessXCFramework copies +# each xcframework's Headers/ into the SHARED $BUILT_PRODUCTS_DIR/include, so a +# top-level include/module.modulemap collides with any other xcframework that +# ships one ("Multiple commands produce .../include/module.modulemap"). Clang +# still resolves `import CNemoTextProcessing` because it looks for a module map +# in a subdirectory named after the module. Keep the directory name == module name. xcodebuild -create-xcframework \ -library "$BUILD_DIR/macos/libtext_processing_rs.a" \ -headers swift/include \ diff --git a/swift/include/module.modulemap b/swift/include/CNemoTextProcessing/module.modulemap similarity index 100% rename from swift/include/module.modulemap rename to swift/include/CNemoTextProcessing/module.modulemap diff --git a/swift/include/nemo_text_processing.h b/swift/include/CNemoTextProcessing/nemo_text_processing.h similarity index 100% rename from swift/include/nemo_text_processing.h rename to swift/include/CNemoTextProcessing/nemo_text_processing.h