@@ -90,6 +90,7 @@ public enum ToolchainVersion: Sendable {
9090
9191 case stable( StableRelease )
9292 case snapshot( Snapshot )
93+ case xcode
9394
9495 public init ( major: Int , minor: Int , patch: Int ) {
9596 self = . stable( StableRelease ( major: major, minor: minor, patch: patch) )
@@ -99,6 +100,8 @@ public enum ToolchainVersion: Sendable {
99100 self = . snapshot( Snapshot ( branch: snapshotBranch, date: date) )
100101 }
101102
103+ public static let xcodeVersion : ToolchainVersion = . xcode
104+
102105 static func stableRegex( ) -> Regex < ( Substring , Substring , Substring , Substring ) > {
103106 try ! Regex ( " ^(?:Swift )?( \\ d+) \\ .( \\ d+) \\ .( \\ d+)$ " )
104107 }
@@ -132,6 +135,8 @@ public enum ToolchainVersion: Sendable {
132135 throw SwiftlyError ( message: " invalid release snapshot version: \( string) " )
133136 }
134137 self = ToolchainVersion ( snapshotBranch: . release( major: major, minor: minor) , date: String ( match. output. 3 ) )
138+ } else if string == " xcode " {
139+ self = ToolchainVersion . xcodeVersion
135140 } else {
136141 throw SwiftlyError ( message: " invalid toolchain version: \" \( string) \" " )
137142 }
@@ -176,6 +181,8 @@ public enum ToolchainVersion: Sendable {
176181 case let . release( major, minor) :
177182 return " \( major) . \( minor) -snapshot- \( release. date) "
178183 }
184+ case . xcode:
185+ return " xcode "
179186 }
180187 }
181188
@@ -194,6 +201,8 @@ public enum ToolchainVersion: Sendable {
194201 case let . release( major, minor) :
195202 return " swift- \( major) . \( minor) -DEVELOPMENT-SNAPSHOT- \( release. date) -a "
196203 }
204+ case . xcode:
205+ return " xcode "
197206 }
198207 }
199208}
@@ -214,6 +223,8 @@ extension ToolchainVersion: CustomStringConvertible {
214223 return " \( release) "
215224 case let . snapshot( snapshot) :
216225 return " \( snapshot) "
226+ case . xcode:
227+ return " xcode "
217228 }
218229 }
219230}
@@ -231,6 +242,10 @@ extension ToolchainVersion: Comparable {
231242 return false
232243 case ( . stable, . snapshot) :
233244 return !( rhs < lhs)
245+ case ( . xcode, . xcode) :
246+ return true
247+ default :
248+ return false
234249 }
235250 }
236251}
@@ -254,6 +269,9 @@ public enum ToolchainSelector: Sendable {
254269 /// associated with the given branch.
255270 case snapshot( branch: ToolchainVersion . Snapshot . Branch , date: String ? )
256271
272+ /// Selects the Xcode of the current system.
273+ case xcode
274+
257275 public init ( major: Int , minor: Int ? = nil , patch: Int ? = nil ) {
258276 self = . stable( major: major, minor: minor, patch: patch)
259277 }
@@ -267,14 +285,19 @@ public enum ToolchainSelector: Sendable {
267285 return
268286 }
269287
288+ if input == " xcode " {
289+ self = Self . xcode
290+ return
291+ }
292+
270293 throw SwiftlyError ( message: " invalid toolchain selector: \" \( input) \" " )
271294 }
272295
273296 public func isReleaseSelector( ) -> Bool {
274297 switch self {
275298 case . latest, . stable:
276299 return true
277- case . snapshot :
300+ default :
278301 return false
279302 }
280303 }
@@ -312,7 +335,8 @@ public enum ToolchainSelector: Sendable {
312335 }
313336 }
314337 return true
315-
338+ case ( . xcode, . xcode) :
339+ return true
316340 default :
317341 return false
318342 }
@@ -341,6 +365,8 @@ extension ToolchainSelector: CustomStringConvertible {
341365 s += " - \( date) "
342366 }
343367 return s
368+ case . xcode:
369+ return " xcode "
344370 }
345371 }
346372}
0 commit comments