Skip to content

Commit 8deef33

Browse files
committed
[PackageDescription4] Add new OS versions in SupportedPlatforms
<rdar://problem/50392890> (cherry picked from commit 0c0461c)
1 parent 01932b5 commit 8deef33

File tree

8 files changed

+69
-6
lines changed

8 files changed

+69
-6
lines changed

Sources/PackageDescription4/SupportedPlatforms.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ extension SupportedPlatform {
186186
///
187187
/// - Since: First available in PackageDescription 5.0
188188
public static let v10_14: MacOSVersion = .init(string: "10.14")
189+
190+
/// macOS 10.15
191+
///
192+
/// - Since: First available in PackageDescription 5.1
193+
@available(_PackageDescription, introduced: 5.1)
194+
public static let v10_15: MacOSVersion = .init(string: "10.15")
189195
}
190196

191197
public struct TVOSVersion: Encodable, AppleOSVersion {
@@ -218,6 +224,12 @@ extension SupportedPlatform {
218224
///
219225
/// - Since: First available in PackageDescription 5.0
220226
public static let v12: TVOSVersion = .init(string: "12.0")
227+
228+
/// tvOS 13.0
229+
///
230+
/// - Since: First available in PackageDescription 5.1
231+
@available(_PackageDescription, introduced: 5.1)
232+
public static let v13: TVOSVersion = .init(string: "13.0")
221233
}
222234

223235
public struct IOSVersion: Encodable, AppleOSVersion {
@@ -255,6 +267,12 @@ extension SupportedPlatform {
255267
///
256268
/// - Since: First available in PackageDescription 5.0
257269
public static let v12: IOSVersion = .init(string: "12.0")
270+
271+
/// iOS 13.0
272+
///
273+
/// - Since: First available in PackageDescription 5.1
274+
@available(_PackageDescription, introduced: 5.1)
275+
public static let v13: IOSVersion = .init(string: "13.0")
258276
}
259277

260278
public struct WatchOSVersion: Encodable, AppleOSVersion {
@@ -287,6 +305,12 @@ extension SupportedPlatform {
287305
///
288306
/// - Since: First available in PackageDescription 5.0
289307
public static let v5: WatchOSVersion = .init(string: "5.0")
308+
309+
/// watchOS 6.0
310+
///
311+
/// - Since: First available in PackageDescription 5.1
312+
@available(_PackageDescription, introduced: 5.1)
313+
public static let v6: WatchOSVersion = .init(string: "6.0")
290314
}
291315
}
292316

Sources/PackageLoading/ManifestLoader.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@ extension ToolsVersion {
7070

7171
// Otherwise, return 4.2
7272
return .v4_2
73+
case 5 where minor < 1:
74+
return .v5
7375

7476
default:
7577
// For rest, return the latest manifest version.
76-
return .v5
78+
return .v5_1
7779
}
7880
}
7981
}

Sources/PackageLoading/PackageBuilder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ public final class PackageBuilder {
367367
// Emit deprecation notice.
368368
switch manifest.manifestVersion {
369369
case .v4: break
370-
case .v4_2, .v5:
370+
case .v4_2, .v5, .v5_1:
371371
diagnostics.emit(
372372
data: PackageBuilderDiagnostics.SystemPackageDeprecatedDiagnostic(),
373373
location: diagnosticLocation()

Sources/PackageModel/Manifest.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public enum ManifestVersion: String, Codable, CustomStringConvertible {
1616
case v4
1717
case v4_2
1818
case v5
19+
case v5_1
1920

2021
/// The Swift language version to use when parsing the manifest file.
2122
public var swiftLanguageVersion: SwiftLanguageVersion {
@@ -30,6 +31,7 @@ public enum ManifestVersion: String, Codable, CustomStringConvertible {
3031
case .v4: return .v4
3132
case .v4_2: return .v4_2
3233
case .v5: return .v5
34+
case .v5_1: return .v5
3335
}
3436
}
3537

@@ -38,6 +40,7 @@ public enum ManifestVersion: String, Codable, CustomStringConvertible {
3840
case .v4: return "4"
3941
case .v4_2: return "4.2"
4042
case .v5: return "5"
43+
case .v5_1: return "5.1"
4144
}
4245
}
4346

@@ -46,7 +49,7 @@ public enum ManifestVersion: String, Codable, CustomStringConvertible {
4649
switch self {
4750
case .v4:
4851
return RelativePath("4")
49-
case .v4_2, .v5:
52+
case .v4_2, .v5, .v5_1:
5053
// PackageDescription 4.2 and 5 are source compatible so they're contained in the same dylib.
5154
return RelativePath("4_2")
5255
}

Sources/PackageModel/Sources.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public enum SupportedLanguageExtension: String {
8181
switch manifestVersion {
8282
case .v4, .v4_2:
8383
return alwaysValidExts
84-
case .v5:
84+
case .v5, .v5_1:
8585
return alwaysValidExts.union(assemblyExtensions)
8686
}
8787
}

Sources/Xcodeproj/pbxproj().swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ func xcodeProject(
428428

429429
// Assign the deployment target if the package is using the newer manifest version.
430430
switch package.manifest.manifestVersion {
431-
case .v5:
431+
case .v5, .v5_1:
432432
for supportedPlatform in target.underlyingTarget.platforms {
433433
let version = supportedPlatform.version.versionString
434434
switch supportedPlatform.platform {

Tests/PackageLoadingTests/PD4LoadingTests.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,22 @@ class PackageDescription4LoadingTests: XCTestCase {
7575
}
7676

7777
let fiveVersions = [
78-
"5.1.0", "6.1.100", "5.0.0", "7.0.0",
78+
"5.0.0", "5.0.1", "5.0.2",
7979
]
8080

8181
for version in fiveVersions {
8282
let toolsVersion = ToolsVersion(string: version)!
8383
XCTAssertEqual(toolsVersion.manifestVersion, .v5, version)
8484
}
85+
86+
let fiveOneVersions = [
87+
"5.1.0", "6.1.100", "5.1.1", "7.0.0",
88+
]
89+
90+
for version in fiveOneVersions {
91+
let toolsVersion = ToolsVersion(string: version)!
92+
XCTAssertEqual(toolsVersion.manifestVersion, .v5_1, version)
93+
}
8594
}
8695

8796
func testTrivial() {

Tests/PackageLoadingTests/PD5LoadingTests.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,31 @@ class PackageDescription5LoadingTests: XCTestCase {
226226
} catch ManifestParseError.runtimeManifestErrors(let errors) {
227227
XCTAssertEqual(errors, ["supported platforms can't be empty"])
228228
}
229+
230+
// Newer OS version.
231+
stream = BufferedOutputByteStream()
232+
stream <<< """
233+
import PackageDescription
234+
let package = Package(
235+
name: "Foo",
236+
platforms: [
237+
.macOS(.v10_15), .iOS(.v13),
238+
]
239+
)
240+
"""
241+
242+
do {
243+
try loadManifestThrowing(stream.bytes) { _ in }
244+
XCTFail("Unexpected success")
245+
} catch {
246+
guard case let ManifestParseError.invalidManifestFormat(message, _) = error else {
247+
return XCTFail("\(error)")
248+
}
249+
250+
XCTAssertMatch(message, .contains("error: 'v10_15' is unavailable"))
251+
XCTAssertMatch(message, .contains("note: 'v10_15' was introduced in PackageDescription 5.1"))
252+
XCTAssertMatch(message, .contains("note: 'v13' was introduced in PackageDescription 5.1"))
253+
}
229254
}
230255

231256
func testBuildSettings() throws {

0 commit comments

Comments
 (0)