Skip to content

Commit 54d1239

Browse files
authored
rdar://93920177 (Adjust SwiftPM 5.7 to minimum supported deployment target changes) (#5598)
Update minimum supported deployment targets and mark older version constants as deprecated in tools-version 5.7. If a package specifies a custom deployment target older than the minimum, the derived one in the model will be automatically raised, similar to how it was alreaady being done for test targets.
1 parent 21c53e9 commit 54d1239

File tree

7 files changed

+46
-31
lines changed

7 files changed

+46
-31
lines changed

Sources/PackageDescription/SupportedPlatforms.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,16 +274,19 @@ extension SupportedPlatform {
274274
/// The value that represents macOS 10.10.
275275
///
276276
/// - Since: First available in PackageDescription 5.0.
277+
@available(_PackageDescription, deprecated: 5.7, message: "macOS 10.13 is the oldest supported version")
277278
public static let v10_10: MacOSVersion = .init(string: "10.10")
278279

279280
/// The value that represents macOS 10.11.
280281
///
281282
/// - Since: First available in PackageDescription 5.0.
283+
@available(_PackageDescription, deprecated: 5.7, message: "macOS 10.13 is the oldest supported version")
282284
public static let v10_11: MacOSVersion = .init(string: "10.11")
283285

284286
/// The value that represents macOS 10.12.
285287
///
286288
/// - Since: First available in PackageDescription 5.0.
289+
@available(_PackageDescription, deprecated: 5.7, message: "macOS 10.13 is the oldest supported version")
287290
public static let v10_12: MacOSVersion = .init(string: "10.12")
288291

289292
/// The value that represents macOS 10.13.
@@ -339,11 +342,13 @@ extension SupportedPlatform {
339342
/// The value that represents tvOS 9.0.
340343
///
341344
/// - Since: First available in PackageDescription 5.0.
345+
@available(_PackageDescription, deprecated: 5.7, message: "tvOS 11.0 is the oldest supported version")
342346
public static let v9: TVOSVersion = .init(string: "9.0")
343347

344348
/// The value that represents tvOS 10.0.
345349
///
346350
/// - Since: First available in PackageDescription 5.0.
351+
@available(_PackageDescription, deprecated: 5.7, message: "tvOS 11.0 is the oldest supported version")
347352
public static let v10: TVOSVersion = .init(string: "10.0")
348353

349354
/// The value that represents tvOS 11.0.
@@ -433,16 +438,19 @@ extension SupportedPlatform {
433438
/// The value that represents iOS 8.0.
434439
///
435440
/// - Since: First available in PackageDescription 5.0.
441+
@available(_PackageDescription, deprecated: 5.7, message: "iOS 11.0 is the oldest supported version")
436442
public static let v8: IOSVersion = .init(string: "8.0")
437443

438444
/// The value that represents iOS 9.0.
439445
///
440446
/// - Since: First available in PackageDescription 5.0.
447+
@available(_PackageDescription, deprecated: 5.7, message: "iOS 11.0 is the oldest supported version")
441448
public static let v9: IOSVersion = .init(string: "9.0")
442449

443450
/// The value that represents iOS 10.0.
444451
///
445452
/// - Since: First available in PackageDescription 5.0.
453+
@available(_PackageDescription, deprecated: 5.7, message: "iOS 11.0 is the oldest supported version")
446454
public static let v10: IOSVersion = .init(string: "10.0")
447455

448456
/// The value that represents iOS 11.0.
@@ -495,11 +503,13 @@ extension SupportedPlatform {
495503
/// The value that represents watchOS 2.0.
496504
///
497505
/// - Since: First available in PackageDescription 5.0.
506+
@available(_PackageDescription, deprecated: 5.7, message: "watchOS 4.0 is the oldest supported version")
498507
public static let v2: WatchOSVersion = .init(string: "2.0")
499508

500509
/// The value that represents watchOS 3.0.
501510
///
502511
/// - Since: First available in PackageDescription 5.0.
512+
@available(_PackageDescription, deprecated: 5.7, message: "watchOS 4.0 is the oldest supported version")
503513
public static let v3: WatchOSVersion = .init(string: "3.0")
504514

505515
/// The value that represents watchOS 4.0.

Sources/PackageGraph/PackageGraph+Loading.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,11 @@ private func computePlatforms(
599599
version = xcTestMinimumDeploymentTarget
600600
}
601601

602+
// If the declared version is smaller than the oldest supported one, we raise the derived version to that.
603+
if version < declaredPlatform.oldestSupportedVersion {
604+
version = declaredPlatform.oldestSupportedVersion
605+
}
606+
602607
let supportedPlatform = SupportedPlatform(
603608
platform: declaredPlatform,
604609
version: version,

Sources/PackageModel/Platform.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ public struct Platform: Equatable, Hashable, Codable {
3131
return Platform(name: name, oldestSupportedVersion: PlatformVersion(oldestSupportedVersion))
3232
}
3333

34-
public static let macOS: Platform = Platform(name: "macos", oldestSupportedVersion: "10.10")
34+
public static let macOS: Platform = Platform(name: "macos", oldestSupportedVersion: "10.13")
3535
public static let macCatalyst: Platform = Platform(name: "maccatalyst", oldestSupportedVersion: "13.0")
36-
public static let iOS: Platform = Platform(name: "ios", oldestSupportedVersion: "9.0")
37-
public static let tvOS: Platform = Platform(name: "tvos", oldestSupportedVersion: "9.0")
38-
public static let watchOS: Platform = Platform(name: "watchos", oldestSupportedVersion: "2.0")
36+
public static let iOS: Platform = Platform(name: "ios", oldestSupportedVersion: "11.0")
37+
public static let tvOS: Platform = Platform(name: "tvos", oldestSupportedVersion: "11.0")
38+
public static let watchOS: Platform = Platform(name: "watchos", oldestSupportedVersion: "4.0")
3939
public static let driverKit: Platform = Platform(name: "driverkit", oldestSupportedVersion: "19.0")
4040
public static let linux: Platform = Platform(name: "linux", oldestSupportedVersion: .unknown)
4141
public static let android: Platform = Platform(name: "android", oldestSupportedVersion: .unknown)

Tests/BuildTests/BuildPlanTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2376,7 +2376,7 @@ final class BuildPlanTests: XCTestCase {
23762376

23772377
let bTarget = try result.target(for: "BTarget").swiftTarget().compileArguments()
23782378
#if os(macOS)
2379-
XCTAssertMatch(bTarget, [.equal("-target"), .equal(hostTriple.tripleString(forPlatformVersion: "10.12")), .anySequence])
2379+
XCTAssertMatch(bTarget, [.equal("-target"), .equal(hostTriple.tripleString(forPlatformVersion: "10.13")), .anySequence])
23802380
#else
23812381
XCTAssertMatch(bTarget, [.equal("-target"), .equal(defaultTargetTriple), .anySequence] )
23822382
#endif

Tests/BuildTests/MockBuildTestHelper.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ extension AbsolutePath {
4545

4646
let hostTriple = UserToolchain.default.triple
4747
#if os(macOS)
48-
let defaultTargetTriple: String = hostTriple.tripleString(forPlatformVersion: "10.10")
48+
let defaultTargetTriple: String = hostTriple.tripleString(forPlatformVersion: "10.13")
4949
#else
5050
let defaultTargetTriple: String = hostTriple.tripleString
5151
#endif

Tests/PackageGraphTests/PackageGraphTests.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,12 +1911,12 @@ class PackageGraphTests: XCTestCase {
19111911

19121912
let defaultDerivedPlatforms = [
19131913
"linux": "0.0",
1914-
"macos": "10.10",
1914+
"macos": "10.13",
19151915
"maccatalyst": "13.0",
1916-
"ios": "9.0",
1917-
"tvos": "9.0",
1916+
"ios": "11.0",
1917+
"tvos": "11.0",
19181918
"driverkit": "19.0",
1919-
"watchos": "2.0",
1919+
"watchos": "4.0",
19201920
"android": "0.0",
19211921
"windows": "0.0",
19221922
"wasi": "0.0",
@@ -1928,7 +1928,7 @@ class PackageGraphTests: XCTestCase {
19281928
let manifest = Manifest.createRootManifest(
19291929
name: "pkg",
19301930
platforms: [
1931-
PlatformDescription(name: "macos", version: "10.12", options: ["option1"]),
1931+
PlatformDescription(name: "macos", version: "10.14", options: ["option1"]),
19321932
],
19331933
products: [
19341934
try ProductDescription(name: "foo", type: .library(.automatic), targets: ["foo"]),
@@ -1946,9 +1946,9 @@ class PackageGraphTests: XCTestCase {
19461946

19471947
let customXCTestMinimumDeploymentTargets = [
19481948
PackageModel.Platform.macOS: PlatformVersion("10.15"),
1949-
PackageModel.Platform.iOS: PlatformVersion("9.0"),
1950-
PackageModel.Platform.tvOS: PlatformVersion("9.0"),
1951-
PackageModel.Platform.watchOS: PlatformVersion("2.0"),
1949+
PackageModel.Platform.iOS: PlatformVersion("11.0"),
1950+
PackageModel.Platform.tvOS: PlatformVersion("11.0"),
1951+
PackageModel.Platform.watchOS: PlatformVersion("4.0"),
19521952
]
19531953

19541954
let observability = ObservabilitySystem.makeForTesting()
@@ -1962,7 +1962,7 @@ class PackageGraphTests: XCTestCase {
19621962

19631963
PackageGraphTester(graph) { result in
19641964
let expectedDeclaredPlatforms = [
1965-
"macos": "10.12"
1965+
"macos": "10.14"
19661966
]
19671967

19681968
// default platforms will be auto-added during package build
@@ -2032,8 +2032,8 @@ class PackageGraphTests: XCTestCase {
20322032
let manifest = Manifest.createRootManifest(
20332033
name: "pkg",
20342034
platforms: [
2035-
PlatformDescription(name: "macos", version: "10.12"),
2036-
PlatformDescription(name: "tvos", version: "10.0"),
2035+
PlatformDescription(name: "macos", version: "10.14"),
2036+
PlatformDescription(name: "tvos", version: "12.0"),
20372037
],
20382038
products: [
20392039
try ProductDescription(name: "foo", type: .library(.automatic), targets: ["foo"]),
@@ -2057,8 +2057,8 @@ class PackageGraphTests: XCTestCase {
20572057

20582058
PackageGraphTester(graph) { result in
20592059
let expectedDeclaredPlatforms = [
2060-
"macos": "10.12",
2061-
"tvos": "10.0",
2060+
"macos": "10.14",
2061+
"tvos": "12.0",
20622062
]
20632063

20642064
// default platforms will be auto-added during package build
@@ -2099,12 +2099,12 @@ class PackageGraphTests: XCTestCase {
20992099

21002100
let defaultDerivedPlatforms = [
21012101
"linux": "0.0",
2102-
"macos": "10.10",
2102+
"macos": "10.13",
21032103
"maccatalyst": "13.0",
2104-
"ios": "9.0",
2105-
"tvos": "9.0",
2104+
"ios": "11.0",
2105+
"tvos": "11.0",
21062106
"driverkit": "19.0",
2107-
"watchos": "2.0",
2107+
"watchos": "4.0",
21082108
"android": "0.0",
21092109
"windows": "0.0",
21102110
"wasi": "0.0",

Tests/XCBuildSupportTests/PIFBuilderTests.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ class PIFBuilderTests: XCTestCase {
186186
XCTAssertEqual(settings[.ENTITLEMENTS_REQUIRED], "NO")
187187
XCTAssertEqual(settings[.GCC_OPTIMIZATION_LEVEL], "0")
188188
XCTAssertEqual(settings[.GCC_PREPROCESSOR_DEFINITIONS], ["$(inherited)", "SWIFT_PACKAGE", "DEBUG=1"])
189-
XCTAssertEqual(settings[.IPHONEOS_DEPLOYMENT_TARGET], "9.0")
189+
XCTAssertEqual(settings[.IPHONEOS_DEPLOYMENT_TARGET], "11.0")
190190
XCTAssertEqual(settings[.IPHONEOS_DEPLOYMENT_TARGET, for: .macCatalyst], "13.0")
191191
XCTAssertEqual(settings[.KEEP_PRIVATE_EXTERNS], "NO")
192-
XCTAssertEqual(settings[.MACOSX_DEPLOYMENT_TARGET], "10.10")
192+
XCTAssertEqual(settings[.MACOSX_DEPLOYMENT_TARGET], "10.13")
193193
XCTAssertEqual(settings[.ONLY_ACTIVE_ARCH], "YES")
194194
XCTAssertEqual(settings[.OTHER_LDRFLAGS], [])
195195
XCTAssertEqual(settings[.PRODUCT_NAME], "$(TARGET_NAME)")
@@ -201,9 +201,9 @@ class PIFBuilderTests: XCTestCase {
201201
XCTAssertEqual(settings[.SWIFT_INSTALL_OBJC_HEADER], "NO")
202202
XCTAssertEqual(settings[.SWIFT_OBJC_INTERFACE_HEADER_NAME], "")
203203
XCTAssertEqual(settings[.SWIFT_OPTIMIZATION_LEVEL], "-Onone")
204-
XCTAssertEqual(settings[.TVOS_DEPLOYMENT_TARGET], "9.0")
204+
XCTAssertEqual(settings[.TVOS_DEPLOYMENT_TARGET], "11.0")
205205
XCTAssertEqual(settings[.USE_HEADERMAP], "NO")
206-
XCTAssertEqual(settings[.WATCHOS_DEPLOYMENT_TARGET], "2.0")
206+
XCTAssertEqual(settings[.WATCHOS_DEPLOYMENT_TARGET], "4.0")
207207

208208
let frameworksSearchPaths = ["$(inherited)", "$(PLATFORM_DIR)/Developer/Library/Frameworks"]
209209
for platform in [PIF.BuildSettings.Platform.macOS, .iOS, .tvOS] {
@@ -232,10 +232,10 @@ class PIFBuilderTests: XCTestCase {
232232
XCTAssertEqual(settings[.ENTITLEMENTS_REQUIRED], "NO")
233233
XCTAssertEqual(settings[.GCC_OPTIMIZATION_LEVEL], "s")
234234
XCTAssertEqual(settings[.GCC_PREPROCESSOR_DEFINITIONS], ["$(inherited)", "SWIFT_PACKAGE"])
235-
XCTAssertEqual(settings[.IPHONEOS_DEPLOYMENT_TARGET], "9.0")
235+
XCTAssertEqual(settings[.IPHONEOS_DEPLOYMENT_TARGET], "11.0")
236236
XCTAssertEqual(settings[.IPHONEOS_DEPLOYMENT_TARGET, for: .macCatalyst], "13.0")
237237
XCTAssertEqual(settings[.KEEP_PRIVATE_EXTERNS], "NO")
238-
XCTAssertEqual(settings[.MACOSX_DEPLOYMENT_TARGET], "10.10")
238+
XCTAssertEqual(settings[.MACOSX_DEPLOYMENT_TARGET], "10.13")
239239
XCTAssertEqual(settings[.OTHER_LDRFLAGS], [])
240240
XCTAssertEqual(settings[.PRODUCT_NAME], "$(TARGET_NAME)")
241241
XCTAssertEqual(settings[.SDK_VARIANT], "auto")
@@ -246,9 +246,9 @@ class PIFBuilderTests: XCTestCase {
246246
XCTAssertEqual(settings[.SWIFT_INSTALL_OBJC_HEADER], "NO")
247247
XCTAssertEqual(settings[.SWIFT_OBJC_INTERFACE_HEADER_NAME], "")
248248
XCTAssertEqual(settings[.SWIFT_OPTIMIZATION_LEVEL], "-Owholemodule")
249-
XCTAssertEqual(settings[.TVOS_DEPLOYMENT_TARGET], "9.0")
249+
XCTAssertEqual(settings[.TVOS_DEPLOYMENT_TARGET], "11.0")
250250
XCTAssertEqual(settings[.USE_HEADERMAP], "NO")
251-
XCTAssertEqual(settings[.WATCHOS_DEPLOYMENT_TARGET], "2.0")
251+
XCTAssertEqual(settings[.WATCHOS_DEPLOYMENT_TARGET], "4.0")
252252

253253
let frameworksSearchPaths = ["$(inherited)", "$(PLATFORM_DIR)/Developer/Library/Frameworks"]
254254
for platform in [PIF.BuildSettings.Platform.macOS, .iOS, .tvOS] {

0 commit comments

Comments
 (0)