@@ -234,7 +234,7 @@ extension Sequence<PackageModel.PackageCondition> {
234234 }
235235
236236 var pifPlatformsForCondition : [ ProjectModel . BuildSettings . Platform ] = platforms
237- . map { ProjectModel . BuildSettings. Platform ( from: $0) }
237+ . compactMap { try ? ProjectModel . BuildSettings. Platform ( from: $0) }
238238
239239 // Treat catalyst like macOS for backwards compatibility with older tools versions.
240240 if pifPlatformsForCondition. contains ( . macOS) , toolsVersion < ToolsVersion . v5_5 {
@@ -565,7 +565,9 @@ extension PackageGraph.ResolvedModule {
565565 let ( platforms, configurations, _) = settingAssignment. conditions. splitIntoConcreteConditions
566566
567567 for platform in platforms {
568- let pifPlatform = platform. map { ProjectModel . BuildSettings. Platform ( from: $0) }
568+ guard let pifPlatform = platform. map ( { try ? ProjectModel . BuildSettings. Platform ( from: $0) } ) else {
569+ continue
570+ }
569571
570572 if pifDeclaration == . OTHER_LDFLAGS {
571573 var settingsByDeclaration : [ ProjectModel . BuildSettings . Declaration : [ String ] ]
@@ -962,7 +964,11 @@ extension ProjectModel.BuildSettings.MultipleValueSetting {
962964}
963965
964966extension ProjectModel . BuildSettings . Platform {
965- init ( from platform: PackageModel . Platform ) {
967+ enum Error : Swift . Error {
968+ case unexpectedPlatform( String )
969+ }
970+
971+ init ( from platform: PackageModel . Platform ) throws {
966972 self = switch platform {
967973 case . macOS: . macOS
968974 case . macCatalyst: . macCatalyst
@@ -977,7 +983,7 @@ extension ProjectModel.BuildSettings.Platform {
977983 case . wasi: . wasi
978984 case . openbsd: . openbsd
979985 case . freebsd: . freebsd
980- default : preconditionFailure ( " Unexpected platform: \ ( platform. name) " )
986+ default : throw Error . unexpectedPlatform ( platform. name)
981987 }
982988 }
983989}
0 commit comments