Skip to content

Commit

Permalink
Fix the support iOS version in Xcode 10.3
Browse files Browse the repository at this point in the history
Fix the support iOS version in Xcode 10.3
  • Loading branch information
Albert Dai committed Aug 23, 2019
1 parent 742b148 commit 586a51b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
38 changes: 25 additions & 13 deletions simulator_control/simulator_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def Delete(self):
preexec_fn=os.setpgrp)
# The delete command won't delete the simulator log directory.
if os.path.exists(self.simulator_log_root_dir):
shutil.rmtree(self.simulator_log_root_dir)
shutil.rmtree(self.simulator_log_root_dir, ignore_errors=True)
self._simulator_id = None

def FetchLogToFile(self, output_file_path, start_time=None, end_time=None):
Expand Down Expand Up @@ -430,6 +430,8 @@ def GetSupportedSimOsVersions(os_type=ios_constants.OS.IOS):
Returns:
a list of string, each item is an OS version number. E.g., ["10.1", "11.0"]
"""
if os_type is None:
os_type = ios_constants.OS.IOS
# Example output:
# {
# "runtimes" : [
Expand Down Expand Up @@ -463,18 +465,28 @@ def GetSupportedSimOsVersions(os_type=ios_constants.OS.IOS):

listed_os_type, listed_os_version = sim_runtime_info['name'].split(' ', 1)
if listed_os_type == os_type:
if os_type == ios_constants.OS.IOS:
ios_major_version, ios_minor_version = listed_os_version.split('.', 1)
# Ingores the potential build version
ios_minor_version = ios_minor_version[0]
ios_version_num = int(ios_major_version) * 100 + int(
ios_minor_version) * 10
# One Xcode version always maps to one max simulator's iOS version.
# The rules is almost max_sim_ios_version <= xcode_version + 200.
# E.g., Xcode 8.3.1/8.3.3 maps to iOS 10.3, Xcode 7.3.1 maps to iOS 9.3.
if ios_version_num > xcode_version_num + 200:
continue
sim_versions.append(listed_os_version)
# `bundlePath` key may not exist in the old Xcode/macOS version.
if 'bundlePath' in sim_runtime_info:
runtime_path = sim_runtime_info['bundlePath']
info_plist_object = plist_util.Plist(
os.path.join(runtime_path, 'Contents/Info.plist'))
min_xcode_version_num = int(info_plist_object.GetPlistField('DTXcode'))
if xcode_version_num >= min_xcode_version_num:
sim_versions.append(listed_os_version)
else:
if os_type == ios_constants.OS.IOS:
ios_major_version, ios_minor_version = listed_os_version.split('.', 1)
# Ingores the potential build version
ios_minor_version = ios_minor_version[0]
ios_version_num = int(ios_major_version) * 100 + int(
ios_minor_version) * 10
# One Xcode version always maps to one max simulator's iOS version.
# The rules is almost max_sim_ios_version <= xcode_version + 200.
# E.g., Xcode 8.3.1/8.3.3 maps to iOS 10.3, Xcode 7.3.1 maps to iOS
# 9.3.
if ios_version_num > xcode_version_num + 200:
continue
sim_versions.append(listed_os_version)
return sim_versions


Expand Down
2 changes: 1 addition & 1 deletion test_runner/logic_test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def RunLogicTestOnSim(
simctl_env_vars[_SIMCTL_ENV_VAR_PREFIX + key] = env_vars[key]
simctl_env_vars['NSUnbufferedIO'] = 'YES'
command = [
'xcrun', 'simctl', 'spawn', '--standalone', sim_id,
'xcrun', 'simctl', 'spawn', '-s', sim_id,
xcode_info_util.GetXctestToolPath(ios_constants.SDK.IPHONESIMULATOR)]
if args:
command += args
Expand Down

0 comments on commit 586a51b

Please sign in to comment.