Skip to content

Commit a539996

Browse files
authored
[main] Enable -user-module-version for 6.0 (#7263)
Summary: `#if canImport(LibFoo, _version: "1.2.3")` is not currently supported by SwiftPM, as this feature was gated on `.vNext`, even though it landed before SwiftPM 5.10 branched off. Steps To Reproduce: 1. Build a package with `// swift-tools-version: 6.0` and try to use `#if canImport(LibFoo, _version: "1.2.3")` for a dependency LibFoo. Results: The availability check won't work because `-user-module-version` option is not passed correctly to the build system.
1 parent e9399c2 commit a539996

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,12 @@ public final class SwiftTargetBuildDescription {
621621
}
622622

623623
// Pass `-user-module-version` for versioned packages that aren't pre-releases.
624-
if let version = package.manifest.version, version.prereleaseIdentifiers.isEmpty, version.buildMetadataIdentifiers.isEmpty, toolsVersion >= .vNext {
624+
if
625+
let version = package.manifest.version,
626+
version.prereleaseIdentifiers.isEmpty &&
627+
version.buildMetadataIdentifiers.isEmpty &&
628+
toolsVersion >= .v6_0
629+
{
625630
args += ["-user-module-version", version.description]
626631
}
627632

Tests/BuildTests/BuildPlanTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6064,7 +6064,7 @@ final class BuildPlanTests: XCTestCase {
60646064
displayName: "ExtPkg",
60656065
path: "/ExtPkg",
60666066
version: "1.0.0",
6067-
toolsVersion: .vNext,
6067+
toolsVersion: .v6_0,
60686068
products: [
60696069
ProductDescription(name: "ExtPkg", type: .library(.automatic), targets: ["ExtLib"]),
60706070
],

0 commit comments

Comments
 (0)