@@ -562,7 +562,7 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder {
562
562
563
563
let generatedModuleMapDir = " $(OBJROOT)/GeneratedModuleMaps/$(PLATFORM_NAME) "
564
564
let moduleMapFile = " \( generatedModuleMapDir) / \( target. name) .modulemap "
565
- let moduleMapFileContents : String
565
+ let moduleMapFileContents : String ?
566
566
567
567
if let clangTarget = target. underlyingTarget as? ClangTarget {
568
568
// Let the target itself find its own headers.
@@ -572,15 +572,20 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder {
572
572
573
573
// Also propagate this search path to all direct and indirect clients.
574
574
impartedSettings [ . HEADER_SEARCH_PATHS, default: [ " $(inherited) " ] ] . append ( clangTarget. includeDir. pathString)
575
- impartedSettings [ . OTHER_SWIFT_FLAGS, default: [ " $(inherited) " ] ] +=
576
- [ " -Xcc " , " -fmodule-map-file= \( moduleMapFile) " ]
577
575
578
- moduleMapFileContents = """
579
- module \( target. c99name) {
580
- umbrella " \( clangTarget. includeDir. pathString) "
581
- export *
582
- }
583
- """
576
+ if !fileSystem. exists ( clangTarget. moduleMapPath) {
577
+ impartedSettings [ . OTHER_SWIFT_FLAGS, default: [ " $(inherited) " ] ] +=
578
+ [ " -Xcc " , " -fmodule-map-file= \( moduleMapFile) " ]
579
+
580
+ moduleMapFileContents = """
581
+ module \( target. c99name) {
582
+ umbrella " \( clangTarget. includeDir. pathString) "
583
+ export *
584
+ }
585
+ """
586
+ } else {
587
+ moduleMapFileContents = nil
588
+ }
584
589
} else if let swiftTarget = target. underlyingTarget as? SwiftTarget {
585
590
settings [ . SWIFT_VERSION] = swiftTarget. swiftVersion. description
586
591
// Generate ObjC compatibility header for Swift library targets.
@@ -597,8 +602,10 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder {
597
602
fatalError ( " unexpected target " )
598
603
}
599
604
600
- settings [ . MODULEMAP_PATH] = moduleMapFile
601
- settings [ . MODULEMAP_FILE_CONTENTS] = moduleMapFileContents
605
+ if let moduleMapFileContents = moduleMapFileContents {
606
+ settings [ . MODULEMAP_PATH] = moduleMapFile
607
+ settings [ . MODULEMAP_FILE_CONTENTS] = moduleMapFileContents
608
+ }
602
609
603
610
// Pass the path of the module map up to all direct and indirect clients.
604
611
impartedSettings [ . OTHER_CFLAGS, default: [ " $(inherited) " ] ] . append ( " -fmodule-map-file= \( moduleMapFile) " )
0 commit comments