Skip to content

Commit 70862aa

Browse files
authored
Align --build-system xcode language mode validation with --build-system native (#8313)
Fix a bug where builds using --build-system xcode would fail if a target was configured to use a language mode which was not also specified at the top level of the package manifest
1 parent ad0cd52 commit 70862aa

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

Sources/XCBuildSupport/PIFBuilder.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -1819,7 +1819,6 @@ extension PIF.BuildSettings {
18191819

18201820
func computeEffectiveSwiftVersions(for versions: [SwiftLanguageVersion]) -> [String] {
18211821
versions
1822-
.filter { target.declaredSwiftVersions.contains($0) }
18231822
.filter { isSupportedVersion($0) }.map(\.description)
18241823
}
18251824

@@ -1937,7 +1936,7 @@ extension PIFGenerationError: CustomStringConvertible {
19371936
versions: let given,
19381937
supportedVersions: let supported
19391938
):
1940-
"Some of the Swift language versions used in target '\(target)' settings are supported. (given: \(given), supported: \(supported))"
1939+
"Some of the Swift language versions used in target '\(target)' settings are unsupported. (given: \(given), supported: \(supported))"
19411940
}
19421941
}
19431942
}

Tests/XCBuildSupportTests/PIFBuilderTests.swift

+12-4
Original file line numberDiff line numberDiff line change
@@ -2947,7 +2947,8 @@ final class PIFBuilderTests: XCTestCase {
29472947
emptyFiles:
29482948
"/Foo/Sources/foo/main.swift",
29492949
"/Foo/Sources/bar/main.swift",
2950-
"/Foo/Sources/baz/main.swift"
2950+
"/Foo/Sources/baz/main.swift",
2951+
"/Foo/Sources/qux/main.swift"
29512952
)
29522953

29532954
let observability = ObservabilitySystem.makeForTesting()
@@ -2958,7 +2959,7 @@ final class PIFBuilderTests: XCTestCase {
29582959
displayName: "Foo",
29592960
path: "/Foo",
29602961
toolsVersion: .v5_3,
2961-
swiftLanguageVersions: [.v4_2, .v5],
2962+
swiftLanguageVersions: [.v4_2],
29622963
targets: [
29632964
.init(name: "foo", dependencies: [], settings: [
29642965
.init(
@@ -2984,6 +2985,12 @@ final class PIFBuilderTests: XCTestCase {
29842985
condition: .init(platformNames: ["macOS"])
29852986
),
29862987
]),
2988+
.init(name: "qux", dependencies: [], settings: [
2989+
.init(
2990+
tool: .swift,
2991+
kind: .swiftLanguageMode(.v5)
2992+
)
2993+
]),
29872994
]
29882995
),
29892996
],
@@ -3001,13 +3008,14 @@ final class PIFBuilderTests: XCTestCase {
30013008

30023009
testDiagnostics(observability.diagnostics) { result in
30033010
result.check(
3004-
diagnostic: "Some of the Swift language versions used in target 'bar' settings are supported. (given: [6], supported: [4.2, 5])",
3011+
diagnostic: "Some of the Swift language versions used in target 'bar' settings are unsupported. (given: [6], supported: [4.2, 5])",
30053012
severity: .error
30063013
)
30073014
result.check(
3008-
diagnostic: "Some of the Swift language versions used in target 'baz' settings are supported. (given: [3], supported: [4.2, 5])",
3015+
diagnostic: "Some of the Swift language versions used in target 'baz' settings are unsupported. (given: [3], supported: [4.2, 5])",
30093016
severity: .error
30103017
)
3018+
result.checkIsEmpty()
30113019
}
30123020
}
30133021
}

0 commit comments

Comments
 (0)