             fatalError("unexpected target")
         }
 
-        settings[.MODULEMAP_PATH] = moduleMapFile
-        settings[.MODULEMAP_FILE_CONTENTS] = moduleMapFileContents
+        if let moduleMapFileContents = moduleMapFileContents {
+            settings[.MODULEMAP_PATH] = moduleMapFile
+            settings[.MODULEMAP_FILE_CONTENTS] = moduleMapFileContents
+        }
 
         // Pass the path of the module map up to all direct and indirect clients.
         impartedSettings[.OTHER_CFLAGS, default: ["$(inherited)"]].append("-fmodule-map-file=\(moduleMapFile)")


            // Also propagate this search path to all direct and indirect clients.
            impartedSettings[.HEADER_SEARCH_PATHS, default: ["$(inherited)"]].append(clangTarget.includeDir.pathString)
            impartedSettings[.OTHER_SWIFT_FLAGS, default: ["$(inherited)"]] +=
                ["-Xcc", "-fmodule-map-file=\(moduleMapFile)"]

            moduleMapFileContents = """
                module \(target.c99name) {
                    umbrella "\(clangTarget.includeDir.pathString)"
                    export *
                }
                """
        } else if let swiftTarget = target.underlyingTarget as? SwiftTarget {
            settings[.SWIFT_VERSION] = swiftTarget.swiftVersion.description
            // Generate ObjC compatibility header for Swift library targets.


        let generatedModuleMapDir = "$(OBJROOT)/GeneratedModuleMaps/$(PLATFORM_NAME)"
        let moduleMapFile = "\(generatedModuleMapDir)/\(target.name).modulemap"
        let moduleMapFileContents: String?

        if let clangTarget = target.underlyingTarget as? ClangTarget {
            // Let the target itself find its own headers.
