Skip to content

Commit 269845f

Browse files
committed
Fix builder factory to handle Swift version 4.2 correctly
Currently if both major and minor versions as specified minor would be stripped out and only major gets set in actual `xcodebuild` flags, but `4.2` is a valid version which has to be supported.
1 parent 66e2c78 commit 269845f

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

project_future.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,19 @@ def dispatch(root_path, repo, action, swiftc, swift_version,
303303

304304
other_swift_flags = []
305305
if swift_version:
306-
other_swift_flags += ['-swift-version', swift_version.split('.')[0]]
307-
initial_xcodebuild_flags += ['SWIFT_VERSION=%s' % swift_version.split('.')[0]]
306+
if '.' not in swift_version:
307+
swift_version += '.0'
308+
309+
major, minor = swift_version.split('.', 1)
310+
# Need to use float for minor version parsing
311+
# because it's possible that it would be specified
312+
# as e.g. `4.0.3`
313+
if int(major) == 4 and float(minor) == 2.0:
314+
other_swift_flags += ['-swift-version', swift_version]
315+
initial_xcodebuild_flags += ['SWIFT_VERSION=%s' % swift_version]
316+
else:
317+
other_swift_flags += ['-swift-version', major]
318+
initial_xcodebuild_flags += ['SWIFT_VERSION=%s' % major]
308319
if added_swift_flags:
309320
other_swift_flags.append(added_swift_flags)
310321
if other_swift_flags:
@@ -982,7 +993,7 @@ def dispatch(self, identifier, stdout=sys.stdout, stderr=sys.stderr):
982993
return None
983994

984995
if not self.swift_version:
985-
self.swift_version = self.version['version'].split('.')[0]
996+
self.swift_version = self.version['version']
986997
try:
987998
dispatch(self.root_path, self.project, self.action,
988999
self.swiftc,

0 commit comments

Comments
 (0)