             env["TOOLCHAINS"] = "default"
         }
         let xcconfig = project.appending(component: "overrides.xcconfig")
-        let swiftCompilerPath = Resources.default.swiftCompiler.asString
-        try localFileSystem.writeFileContents(xcconfig) {
-            $0 <<< "SWIFT_EXEC = " <<< swiftCompilerPath
+        let swiftCompilerPath = Resources.default.swiftCompiler
+
+        // Override path to the Swift compiler.
+        let stream = BufferedOutputByteStream()
+        stream <<< "SWIFT_EXEC = " <<< swiftCompilerPath.asString <<< "\n"
+
+        // Override Swift libary path, if present.
+        let swiftLibraryPath = resolveSymlinks(swiftCompilerPath).appending(components: "..", "..", "lib", "swift", "macosx")
+        if localFileSystem.exists(swiftCompilerPath) {
+            stream <<< "SWIFT_LIBRARY_PATH = " <<< swiftLibraryPath.asString <<< "\n"
         }
+        try localFileSystem.writeFileContents(xcconfig, bytes: stream.bytes)
+
         try Process.checkNonZeroExit(
             args: "xcodebuild", "-project", project.asString, "-alltargets", "-xcconfig", xcconfig.asString, environment: env)
     } catch {

    }

    func testSwiftExecWithCDep() {
#if false
        fixture(name: "ClangModules/SwiftCMixed") { prefix in
            // This will also test Modulemap generation for xcodeproj.
            XCTAssertXcodeprojGen(prefix)

    }
    
    func testSystemModule() {
#if os(macOS)
        // Because there isn't any one system target that we can depend on for testing purposes, we build our own.
        try! write(path: AbsolutePath("/tmp/fake.h")) { stream in
            stream <<< "extern const char GetFakeString(void);\n"
