Skip to content

Commit

Permalink
Make Xcode version check more lenient
Browse files Browse the repository at this point in the history
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
  • Loading branch information
keith committed Oct 12, 2022
1 parent 5d832bf commit 969cbeb
Showing 1 changed file with 13 additions and 28 deletions.
41 changes: 13 additions & 28 deletions utils/build-script
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The ultimate tool for building Swift.
import json
import os
import platform
import re
import sys
import time

Expand All @@ -43,24 +44,6 @@ from swift_build_support.swift_build_support.utils import fatal_error
from swift_build_support.swift_build_support.utils import log_analyzer


# -----------------------------------------------------------------------------
# Constants

# These versions are community sourced. At any given time only the Xcode
# version used by Swift CI is officially supported. See ci.swift.org
_SUPPORTED_XCODE_BUILDS = [
("13.0 beta 4", "13A5201i"),
("13.0", "13A233"),
("13.1 RC 1", "13A1030d"),
("13.2 beta", "13C5066c"),
("13.2.1", "13C100"),
("13.3", "13E113"),
("13.3.1", "13E500a"),
("13.4", "13F17a"),
("13.4.1", "13F100"),
("14.0.0", "14A309"),
]

# -----------------------------------------------------------------------------
# Helpers

Expand Down Expand Up @@ -148,19 +131,21 @@ def validate_xcode_compatibility():
print("note: skipping Xcode version check")
return

version = shell.capture(
output = shell.capture(
['xcodebuild', '-version'], dry_run=False, echo=False).strip()
# Capture only version ex: '14.x' from full output
match = re.match(r"Xcode (\d+\.\d+(?:\.\d)?)", output)
if not match:
print(f"warning: unexpected xcodebuild output format: '{output}', skipping Xcode compatibility check, please report this issue", file=sys.stderr)
return

valid_build_numbers = tuple(x[1] for x in _SUPPORTED_XCODE_BUILDS)
if not version.endswith(valid_build_numbers):
valid_versions_string = "\n".join(
"{} ({})".format(*x) for x in _SUPPORTED_XCODE_BUILDS)
version = match.group(1)
minimum_version = "13.0"
if version < minimum_version:
raise SystemExit(
"error: using unsupported Xcode version:\n\n{}\n\n"
"Install one of:\n{}\n\n"
"Or set 'SKIP_XCODE_VERSION_CHECK=1' in the environment".format(
version, valid_versions_string
)
f"error: using unsupported Xcode version '{version}'. "
f"Install Xcode {minimum_version} or newer, "
"or set 'SKIP_XCODE_VERSION_CHECK=1' in the environment"
)


Expand Down

0 comments on commit 969cbeb

Please sign in to comment.