Skip to content

Commit 486c801

Browse files
committed
Merge remote-tracking branch 'origin/main' into release/6.1
2 parents ce045ce + d2a9630 commit 486c801

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Sources/Build/BuildDescription/SwiftModuleBuildDescription.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,15 @@ public final class SwiftModuleBuildDescription {
982982
if self.isTestTarget {
983983
// test targets must be built with -enable-testing
984984
// since its required for test discovery (the non objective-c reflection kind)
985-
return ["-enable-testing"]
985+
var result = ["-enable-testing"]
986+
987+
// Test targets need to enable cross-import overlays because Swift
988+
// Testing cannot directly link to most other modules and needs to
989+
// provide API that works with e.g. Foundation. (Developers can
990+
// override this flag by passing -disable-cross-import-overlays.)
991+
result += ["-Xfrontend", "-enable-cross-import-overlays"]
992+
993+
return result
986994
} else if self.buildParameters.enableTestability {
987995
return ["-enable-testing"]
988996
} else {

Tests/BuildTests/BuildPlanTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,6 +2337,8 @@ final class BuildPlanTests: XCTestCase {
23372337
"-enable-batch-mode",
23382338
"-Onone",
23392339
"-enable-testing",
2340+
"-Xfrontend",
2341+
"-enable-cross-import-overlays",
23402342
.equal(self.j),
23412343
"-DSWIFT_PACKAGE",
23422344
"-DDEBUG",

0 commit comments

Comments
 (0)