@@ -1396,6 +1396,63 @@ struct BuildCommandTestCases {
1396
1396
}
1397
1397
}
1398
1398
}
1399
+
1400
+ @Test ( . requireHostOS( . macOS) , arguments: SupportedBuildSystemOnPlatform)
1401
+ func buildingPackageWhichRequiresOlderDeploymentTarget( buildSystem: BuildSystemProvider . Kind ) async throws {
1402
+ // This fixture specifies a deployment target of macOS 12, and uses API obsoleted in macOS 13. The goal
1403
+ // of this test is to ensure that SwiftPM respects the deployment target specified in the package manifest
1404
+ // when passed no triple of an unversioned triple, rather than using the latests deployment target.
1405
+
1406
+ // No triple - build should pass
1407
+ try await fixture ( name: " Miscellaneous/RequiresOlderDeploymentTarget " ) { path in
1408
+ try await executeSwiftBuild (
1409
+ path,
1410
+ buildSystem: buildSystem,
1411
+ throwIfCommandFails: true
1412
+ )
1413
+ }
1414
+
1415
+ let hostArch : String
1416
+ #if arch(arm64)
1417
+ hostArch = " arm64 "
1418
+ #else
1419
+ hostArch = " x86_64 "
1420
+ #endif
1421
+
1422
+ // Unversioned triple - build should pass
1423
+ try await fixture ( name: " Miscellaneous/RequiresOlderDeploymentTarget " ) { path in
1424
+ try await executeSwiftBuild (
1425
+ path,
1426
+ extraArgs: [ " --triple " , " \( hostArch) -apple-macosx " ] ,
1427
+ buildSystem: buildSystem,
1428
+ throwIfCommandFails: true
1429
+ )
1430
+ }
1431
+
1432
+ // Versioned triple with supported deployment target - build should pass
1433
+ try await fixture ( name: " Miscellaneous/RequiresOlderDeploymentTarget " ) { path in
1434
+ try await executeSwiftBuild (
1435
+ path,
1436
+ extraArgs: [ " --triple " , " \( hostArch) -apple-macosx12.0 " ] ,
1437
+ buildSystem: buildSystem,
1438
+ throwIfCommandFails: true
1439
+ )
1440
+ }
1441
+
1442
+ if buildSystem == . swiftbuild {
1443
+ // Versioned triple with unsupported deployment target - build should fail
1444
+ try await fixture ( name: " Miscellaneous/RequiresOlderDeploymentTarget " ) { path in
1445
+ await #expect( throws: Error . self) {
1446
+ try await executeSwiftBuild (
1447
+ path,
1448
+ extraArgs: [ " --triple " , " \( hostArch) -apple-macosx14.0 " ] ,
1449
+ buildSystem: buildSystem,
1450
+ throwIfCommandFails: true
1451
+ )
1452
+ }
1453
+ }
1454
+ }
1455
+ }
1399
1456
}
1400
1457
1401
1458
extension Triple {
0 commit comments