@@ -145,7 +145,13 @@ extension PackageGraph {
145145 rootManifests: root. manifests,
146146 unsafeAllowedPackages: unsafeAllowedPackages,
147147 platformRegistry: customPlatformsRegistry ?? . default,
148- xcTestMinimumDeploymentTargets: customXCTestMinimumDeploymentTargets ?? MinimumDeploymentTarget . default. xcTestMinimumDeploymentTargets,
148+ deriveXCTestPlatform: { declared in
149+ if let customXCTestMinimumDeploymentTargets = customXCTestMinimumDeploymentTargets {
150+ return customXCTestMinimumDeploymentTargets [ declared]
151+ } else {
152+ return MinimumDeploymentTarget . default. computeXCTestMinimumDeploymentTarget ( for: declared)
153+ }
154+ } ,
149155 fileSystem: fileSystem,
150156 observabilityScope: observabilityScope
151157 )
@@ -226,7 +232,7 @@ private func createResolvedPackages(
226232 rootManifests: [ PackageIdentity : Manifest ] ,
227233 unsafeAllowedPackages: Set < PackageReference > ,
228234 platformRegistry: PlatformRegistry ,
229- xcTestMinimumDeploymentTargets : [ PackageModel . Platform : PlatformVersion ] ,
235+ deriveXCTestPlatform : @escaping ( _ declared : PackageModel . Platform ) -> PlatformVersion ? ,
230236 fileSystem: FileSystem ,
231237 observabilityScope: ObservabilityScope
232238) throws -> [ ResolvedPackage ] {
@@ -349,16 +355,8 @@ private func createResolvedPackages(
349355
350356 packageBuilder. platforms = computePlatforms (
351357 package : package ,
352- usingXCTest: false ,
353- platformRegistry: platformRegistry,
354- xcTestMinimumDeploymentTargets: xcTestMinimumDeploymentTargets
355- )
356-
357- let testPlatforms = computePlatforms (
358- package : package ,
359- usingXCTest: true ,
360358 platformRegistry: platformRegistry,
361- xcTestMinimumDeploymentTargets : xcTestMinimumDeploymentTargets
359+ deriveXCTestPlatform : deriveXCTestPlatform
362360 )
363361
364362 // Create target builders for each target in the package.
@@ -380,7 +378,7 @@ private func createResolvedPackages(
380378 }
381379 }
382380 targetBuilder. defaultLocalization = packageBuilder. defaultLocalization
383- targetBuilder. platforms = targetBuilder . target . type == . test ? testPlatforms : packageBuilder. platforms
381+ targetBuilder. platforms = packageBuilder. platforms
384382 }
385383
386384 // Create product builders for each product in the package. A product can only contain a target present in the same package.
@@ -734,9 +732,8 @@ private class DuplicateProductsChecker {
734732
735733private func computePlatforms(
736734 package : Package ,
737- usingXCTest: Bool ,
738735 platformRegistry: PlatformRegistry ,
739- xcTestMinimumDeploymentTargets : [ PackageModel . Platform : PlatformVersion ]
736+ deriveXCTestPlatform : @escaping ( _ declared : PackageModel . Platform ) -> PlatformVersion ?
740737) -> SupportedPlatforms {
741738
742739 // the supported platforms as declared in the manifest
@@ -750,67 +747,9 @@ private func computePlatforms(
750747 )
751748 }
752749
753- // the derived platforms based on known minimum deployment target logic
754- var derivedPlatforms = [ SupportedPlatform] ( )
755-
756- /// Add each declared platform to the supported platforms list.
757- for platform in package . manifest. platforms {
758- let declaredPlatform = platformRegistry. platformByName [ platform. platformName]
759- ?? PackageModel . Platform. custom ( name: platform. platformName, oldestSupportedVersion: platform. version)
760- var version = PlatformVersion ( platform. version)
761-
762- if usingXCTest, let xcTestMinimumDeploymentTarget = xcTestMinimumDeploymentTargets [ declaredPlatform] , version < xcTestMinimumDeploymentTarget {
763- version = xcTestMinimumDeploymentTarget
764- }
765-
766- // If the declared version is smaller than the oldest supported one, we raise the derived version to that.
767- if version < declaredPlatform. oldestSupportedVersion {
768- version = declaredPlatform. oldestSupportedVersion
769- }
770-
771- let supportedPlatform = SupportedPlatform (
772- platform: declaredPlatform,
773- version: version,
774- options: platform. options
775- )
776-
777- derivedPlatforms. append ( supportedPlatform)
778- }
779-
780- // Find the undeclared platforms.
781- let remainingPlatforms = Set ( platformRegistry. platformByName. keys) . subtracting ( derivedPlatforms. map ( { $0. platform. name } ) )
782-
783- /// Start synthesizing for each undeclared platform.
784- for platformName in remainingPlatforms. sorted ( ) {
785- let platform = platformRegistry. platformByName [ platformName] !
786-
787- let minimumSupportedVersion : PlatformVersion
788- if usingXCTest, let xcTestMinimumDeploymentTarget = xcTestMinimumDeploymentTargets [ platform] , xcTestMinimumDeploymentTarget > platform. oldestSupportedVersion {
789- minimumSupportedVersion = xcTestMinimumDeploymentTarget
790- } else {
791- minimumSupportedVersion = platform. oldestSupportedVersion
792- }
793-
794- let oldestSupportedVersion : PlatformVersion
795- if platform == . macCatalyst, let iOS = derivedPlatforms. first ( where: { $0. platform == . iOS } ) {
796- // If there was no deployment target specified for Mac Catalyst, fall back to the iOS deployment target.
797- oldestSupportedVersion = max ( minimumSupportedVersion, iOS. version)
798- } else {
799- oldestSupportedVersion = minimumSupportedVersion
800- }
801-
802- let supportedPlatform = SupportedPlatform (
803- platform: platform,
804- version: oldestSupportedVersion,
805- options: [ ]
806- )
807-
808- derivedPlatforms. append ( supportedPlatform)
809- }
810-
811750 return SupportedPlatforms (
812751 declared: declaredPlatforms. sorted ( by: { $0. platform. name < $1. platform. name } ) ,
813- derived : derivedPlatforms . sorted ( by : { $0 . platform . name < $1 . platform . name } )
752+ deriveXCTestPlatform : deriveXCTestPlatform
814753 )
815754}
816755
@@ -934,7 +873,7 @@ private final class ResolvedTargetBuilder: ResolvedBuilder<ResolvedTarget> {
934873 var defaultLocalization : String ? = nil
935874
936875 /// The platforms supported by this package.
937- var platforms : SupportedPlatforms = . init( declared: [ ] , derived : [ ] )
876+ var platforms : SupportedPlatforms = . init( declared: [ ] , deriveXCTestPlatform : { _ in nil } )
938877
939878 init (
940879 target: Target ,
@@ -1026,7 +965,7 @@ private final class ResolvedPackageBuilder: ResolvedBuilder<ResolvedPackage> {
1026965 var defaultLocalization : String ? = nil
1027966
1028967 /// The platforms supported by this package.
1029- var platforms : SupportedPlatforms = . init( declared: [ ] , derived : [ ] )
968+ var platforms : SupportedPlatforms = . init( declared: [ ] , deriveXCTestPlatform : { _ in nil } )
1030969
1031970 /// If the given package's source is a registry release, this provides additional metadata and signature information.
1032971 var registryMetadata : RegistryReleaseMetadata ?
0 commit comments