@@ -32,6 +32,9 @@ public enum DarwinPlatform: Hashable {
3232 /// watchOS, corresponding to the `watchos` OS name.
3333 case watchOS( EnvironmentWithoutCatalyst )
3434
35+ /// visionOS, corresponding to the `visionos` OS name.
36+ case visionOS( EnvironmentWithoutCatalyst )
37+
3538 /// The most general form of environment information attached to a
3639 /// `DarwinPlatform`.
3740 ///
@@ -76,6 +79,9 @@ public enum DarwinPlatform: Hashable {
7679 case . watchOS:
7780 guard let withoutCatalyst = environment. withoutCatalyst else { return nil }
7881 return . watchOS( withoutCatalyst)
82+ case . visionOS:
83+ guard let withoutCatalyst = environment. withoutCatalyst else { return nil }
84+ return . visionOS( withoutCatalyst)
7985 }
8086 }
8187
@@ -97,6 +103,10 @@ public enum DarwinPlatform: Hashable {
97103 return " watchOS "
98104 case . watchOS( . simulator) :
99105 return " watchOS Simulator "
106+ case . visionOS( . device) :
107+ return " visionOS "
108+ case . visionOS( . simulator) :
109+ return " visionOS Simulator "
100110 }
101111 }
102112
@@ -120,6 +130,10 @@ public enum DarwinPlatform: Hashable {
120130 return " watchos "
121131 case . watchOS( . simulator) :
122132 return " watchsimulator "
133+ case . visionOS( . device) :
134+ return " xros "
135+ case . visionOS( . simulator) :
136+ return " xrsimulator "
123137 }
124138 }
125139
@@ -142,6 +156,10 @@ public enum DarwinPlatform: Hashable {
142156 return " watchos "
143157 case . watchOS( . simulator) :
144158 return " watchos-simulator "
159+ case . visionOS( . device) :
160+ return " xros "
161+ case . visionOS( . simulator) :
162+ return " xros-simulator "
145163 }
146164 }
147165
@@ -165,6 +183,10 @@ public enum DarwinPlatform: Hashable {
165183 return " watchos "
166184 case . watchOS( . simulator) :
167185 return " watchossim "
186+ case . visionOS( . device) :
187+ return " xros "
188+ case . visionOS( . simulator) :
189+ return " xrossim "
168190 }
169191 }
170192}
@@ -197,6 +219,8 @@ extension Triple {
197219 return _iOSVersion
198220 case . watchOS:
199221 return _watchOSVersion
222+ case . visionOS:
223+ return _visionOSVersion
200224 }
201225 }
202226
@@ -223,6 +247,8 @@ extension Triple {
223247 return . watchOS( makeEnvironment ( ) )
224248 case . tvos:
225249 return . tvOS( makeEnvironment ( ) )
250+ case . visionos:
251+ return . visionOS( makeEnvironment ( ) )
226252 default :
227253 return nil
228254 }
@@ -272,6 +298,8 @@ extension Triple {
272298 }
273299
274300 return osVersion
301+ case . visionOS( _) :
302+ return _visionOSVersion
275303 }
276304 }
277305
@@ -285,7 +313,7 @@ extension Triple {
285313 switch os {
286314 case nil :
287315 fatalError ( " unknown OS " )
288- case . darwin, . macosx, . ios, . tvos, . watchos:
316+ case . darwin, . macosx, . ios, . tvos, . watchos, . visionos :
289317 guard let darwinPlatform = darwinPlatform else {
290318 fatalError ( " unsupported darwin platform kind? " )
291319 }
@@ -361,6 +389,7 @@ extension Triple {
361389 public let iOS : Availability
362390 public let tvOS : Availability
363391 public let watchOS : Availability
392+ public var visionOS : Availability
364393
365394 // TODO: We should have linux, windows, etc.
366395 public let nonDarwin : Bool
@@ -379,8 +408,14 @@ extension Triple {
379408 self . tvOS = tvOS
380409 self . watchOS = watchOS
381410 self . nonDarwin = nonDarwin
411+ self . visionOS = iOS
382412 }
383413
414+ public func withVisionOS( _ visionOS: Availability ) -> FeatureAvailability {
415+ var res = self
416+ res. visionOS = visionOS
417+ return res
418+ }
384419 /// Returns the version when the feature was introduced on the specified Darwin
385420 /// platform, or `.unavailable` if the feature has not been introduced there.
386421 public subscript( darwinPlatform: DarwinPlatform ) -> Availability {
@@ -393,6 +428,8 @@ extension Triple {
393428 return tvOS
394429 case . watchOS:
395430 return watchOS
431+ case . visionOS:
432+ return visionOS
396433 }
397434 }
398435 }
0 commit comments