@@ -17,6 +17,7 @@ The ultimate tool for building Swift.
17
17
import json
18
18
import os
19
19
import platform
20
+ import re
20
21
import sys
21
22
import time
22
23
@@ -43,24 +44,6 @@ from swift_build_support.swift_build_support.utils import fatal_error
43
44
from swift_build_support .swift_build_support .utils import log_analyzer
44
45
45
46
46
- # -----------------------------------------------------------------------------
47
- # Constants
48
-
49
- # These versions are community sourced. At any given time only the Xcode
50
- # version used by Swift CI is officially supported. See ci.swift.org
51
- _SUPPORTED_XCODE_BUILDS = [
52
- ("13.0 beta 4" , "13A5201i" ),
53
- ("13.0" , "13A233" ),
54
- ("13.1 RC 1" , "13A1030d" ),
55
- ("13.2 beta" , "13C5066c" ),
56
- ("13.2.1" , "13C100" ),
57
- ("13.3" , "13E113" ),
58
- ("13.3.1" , "13E500a" ),
59
- ("13.4" , "13F17a" ),
60
- ("13.4.1" , "13F100" ),
61
- ("14.0.0" , "14A309" ),
62
- ]
63
-
64
47
# -----------------------------------------------------------------------------
65
48
# Helpers
66
49
@@ -148,19 +131,24 @@ def validate_xcode_compatibility():
148
131
print ("note: skipping Xcode version check" )
149
132
return
150
133
151
- version = shell .capture (
134
+ output = shell .capture (
152
135
['xcodebuild' , '-version' ], dry_run = False , echo = False ).strip ()
136
+ # Capture only version ex: '14.x' from full output
137
+ match = re .match (r"Xcode (\d+\.\d+(?:\.\d)?)" , output )
138
+ if not match :
139
+ print (f"warning: unexpected xcodebuild output format: '{ output } ', "
140
+ "skipping Xcode compatibility check, please report this issue" ,
141
+ file = sys .stderr )
142
+ return
153
143
154
- valid_build_numbers = tuple ( x [ 1 ] for x in _SUPPORTED_XCODE_BUILDS )
155
- if not version . endswith ( valid_build_numbers ):
156
- valid_versions_string = " \n " . join (
157
- "{} ({})" . format ( * x ) for x in _SUPPORTED_XCODE_BUILDS )
144
+ version_match = match . group ( 1 )
145
+ current_version = tuple ( int ( v ) for v in version_match . replace ( '.' , ' ' ). split ())
146
+ minimum_version = ( 13 , 0 )
147
+ if current_version < minimum_version :
158
148
raise SystemExit (
159
- "error: using unsupported Xcode version:\n \n {}\n \n "
160
- "Install one of:\n {}\n \n "
161
- "Or set 'SKIP_XCODE_VERSION_CHECK=1' in the environment" .format (
162
- version , valid_versions_string
163
- )
149
+ f"error: using unsupported Xcode version '{ version_match } '. "
150
+ f"Install Xcode { '.' .join (str (x ) for x in minimum_version )} or newer, "
151
+ "or set 'SKIP_XCODE_VERSION_CHECK=1' in the environment"
164
152
)
165
153
166
154
0 commit comments