Skip to content

Commit 6dec900

Browse files
authored
rdar://93920177 (Adjust SwiftPM 5.7 to minimum supported deployment target changes) (#5603)
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. (cherry picked from commit 54d1239)
1 parent 0c0b019 commit 6dec900

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
@@ -2020,7 +2020,7 @@ final class BuildPlanTests: XCTestCase {
20202020

20212021
let bTarget = try result.target(for: "BTarget").swiftTarget().compileArguments()
20222022
#if os(macOS)
2023-
XCTAssertMatch(bTarget, [.equal("-target"), .equal(hostTriple.tripleString(forPlatformVersion: "10.12")), .anySequence])
2023+
XCTAssertMatch(bTarget, [.equal("-target"), .equal(hostTriple.tripleString(forPlatformVersion: "10.13")), .anySequence])
20242024
#else
20252025
XCTAssertMatch(bTarget, [.equal("-target"), .equal(defaultTargetTriple), .anySequence] )
20262026
#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
@@ -1909,12 +1909,12 @@ class PackageGraphTests: XCTestCase {
19091909

19101910
let defaultDerivedPlatforms = [
19111911
"linux": "0.0",
1912-
"macos": "10.10",
1912+
"macos": "10.13",
19131913
"maccatalyst": "13.0",
1914-
"ios": "9.0",
1915-
"tvos": "9.0",
1914+
"ios": "11.0",
1915+
"tvos": "11.0",
19161916
"driverkit": "19.0",
1917-
"watchos": "2.0",
1917+
"watchos": "4.0",
19181918
"android": "0.0",
19191919
"windows": "0.0",
19201920
"wasi": "0.0",
@@ -1926,7 +1926,7 @@ class PackageGraphTests: XCTestCase {
19261926
let manifest = Manifest.createRootManifest(
19271927
name: "pkg",
19281928
platforms: [
1929-
PlatformDescription(name: "macos", version: "10.12", options: ["option1"]),
1929+
PlatformDescription(name: "macos", version: "10.14", options: ["option1"]),
19301930
],
19311931
products: [
19321932
try ProductDescription(name: "foo", type: .library(.automatic), targets: ["foo"]),
@@ -1944,9 +1944,9 @@ class PackageGraphTests: XCTestCase {
19441944

19451945
let customXCTestMinimumDeploymentTargets = [
19461946
PackageModel.Platform.macOS: PlatformVersion("10.15"),
1947-
PackageModel.Platform.iOS: PlatformVersion("9.0"),
1948-
PackageModel.Platform.tvOS: PlatformVersion("9.0"),
1949-
PackageModel.Platform.watchOS: PlatformVersion("2.0"),
1947+
PackageModel.Platform.iOS: PlatformVersion("11.0"),
1948+
PackageModel.Platform.tvOS: PlatformVersion("11.0"),
1949+
PackageModel.Platform.watchOS: PlatformVersion("4.0"),
19501950
]
19511951

19521952
let observability = ObservabilitySystem.makeForTesting()
@@ -1960,7 +1960,7 @@ class PackageGraphTests: XCTestCase {
19601960

19611961
PackageGraphTester(graph) { result in
19621962
let expectedDeclaredPlatforms = [
1963-
"macos": "10.12"
1963+
"macos": "10.14"
19641964
]
19651965

19661966
// default platforms will be auto-added during package build
@@ -2030,8 +2030,8 @@ class PackageGraphTests: XCTestCase {
20302030
let manifest = Manifest.createRootManifest(
20312031
name: "pkg",
20322032
platforms: [
2033-
PlatformDescription(name: "macos", version: "10.12"),
2034-
PlatformDescription(name: "tvos", version: "10.0"),
2033+
PlatformDescription(name: "macos", version: "10.14"),
2034+
PlatformDescription(name: "tvos", version: "12.0"),
20352035
],
20362036
products: [
20372037
try ProductDescription(name: "foo", type: .library(.automatic), targets: ["foo"]),
@@ -2055,8 +2055,8 @@ class PackageGraphTests: XCTestCase {
20552055

20562056
PackageGraphTester(graph) { result in
20572057
let expectedDeclaredPlatforms = [
2058-
"macos": "10.12",
2059-
"tvos": "10.0",
2058+
"macos": "10.14",
2059+
"tvos": "12.0",
20602060
]
20612061

20622062
// default platforms will be auto-added during package build
@@ -2097,12 +2097,12 @@ class PackageGraphTests: XCTestCase {
20972097

20982098
let defaultDerivedPlatforms = [
20992099
"linux": "0.0",
2100-
"macos": "10.10",
2100+
"macos": "10.13",
21012101
"maccatalyst": "13.0",
2102-
"ios": "9.0",
2103-
"tvos": "9.0",
2102+
"ios": "11.0",
2103+
"tvos": "11.0",
21042104
"driverkit": "19.0",
2105-
"watchos": "2.0",
2105+
"watchos": "4.0",
21062106
"android": "0.0",
21072107
"windows": "0.0",
21082108
"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)