Skip to content

Commit 6a32e91

Browse files
committed
Make Xcode version check more lenient
This allows any versions above a specific version, instead of requiring a specific list. Since it seems like many folks just disable this check entirely, this list definitely isn't kept up well. If we need to exclude a specific version, like if 1 Xcode beta didn't support it but the next did, we can add a new list using the old method to validate build numbers and disallow the bad version(s). I don't recall why we didn't do this over a list originally, nor can I find any context on why in the original discussion swiftlang#34227
1 parent 9a9cfab commit 6a32e91

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

utils/build-script

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ The ultimate tool for building Swift.
1717
import json
1818
import os
1919
import platform
20+
import re
2021
import sys
2122
import time
2223

@@ -43,24 +44,6 @@ from swift_build_support.swift_build_support.utils import fatal_error
4344
from swift_build_support.swift_build_support.utils import log_analyzer
4445

4546

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-
6447
# -----------------------------------------------------------------------------
6548
# Helpers
6649

@@ -148,19 +131,24 @@ def validate_xcode_compatibility():
148131
print("note: skipping Xcode version check")
149132
return
150133

151-
version = shell.capture(
134+
output = shell.capture(
152135
['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
153143

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:
158148
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"
164152
)
165153

166154

0 commit comments

Comments
 (0)