def GetLastSupportedSimOsVersion(os_type=ios_constants.OS.IOS, device_type=None):
    'Gets the last supported version of given arguments.\n\n  If device_type is given, will return the last supported OS version of the\n  device type. Otherwise, will return the last supported OS version of the\n  OS type.\n\n  Args:\n    os_type: shared.ios_constants.OS, OS type of simulator, such as iOS,\n      watchOS, tvOS.\n    device_type: string, device type of the new simulator. The value corresponds\n      to the output of `xcrun simctl list devicetypes`. E.g., iPhone 6, iPad\n      Air, etc.\n\n  Returns:\n    a string, the last supported version.\n\n  Raises:\n    ios_errors.SimError: when there is no supported OS version of the given OS.\n    ios_errors.IllegalArgumentError: when the supported OS version can not match\n        the given simulator type.\n  '
    supported_os_versions = GetSupportedSimOsVersions(os_type)
    if (not supported_os_versions):
        raise ios_errors.SimError(('Can not find supported OS version of %s.' % os_type))
    if (not device_type):
        return supported_os_versions[(- 1)]
    simtype_max_os_version_float = float(simtype_profile.SimTypeProfile(device_type).max_os_version)
    supported_os_versions.reverse()
    for os_version in supported_os_versions:
        if (float(os_version) <= simtype_max_os_version_float):
            return os_version
    if (not supported_os_versions):
        raise ios_errors.IllegalArgumentError(('The supported OS version %s can not match simulator type %s. Because its max OS version is %s' % (supported_os_versions, device_type, simtype_max_os_version_float)))
Gets the last supported version of given arguments.

If device_type is given, will return the last supported OS version of the
device type. Otherwise, will return the last supported OS version of the
OS type.

Args:
  os_type: shared.ios_constants.OS, OS type of simulator, such as iOS,
    watchOS, tvOS.
  device_type: string, device type of the new simulator. The value corresponds
    to the output of `xcrun simctl list devicetypes`. E.g., iPhone 6, iPad
    Air, etc.

Returns:
  a string, the last supported version.

Raises:
  ios_errors.SimError: when there is no supported OS version of the given OS.
  ios_errors.IllegalArgumentError: when the supported OS version can not match
      the given simulator type.
def GetLastSupportedSimOsVersion(os_type=ios_constants.OS.IOS, device_type=None):
    'Gets the last supported version of given arguments.\n\n  If device_type is given, will return the last supported OS version of the\n  device type. Otherwise, will return the last supported OS version of the\n  OS type.\n\n  Args:\n    os_type: shared.ios_constants.OS, OS type of simulator, such as iOS,\n      watchOS, tvOS.\n    device_type: string, device type of the new simulator. The value corresponds\n      to the output of `xcrun simctl list devicetypes`. E.g., iPhone 6, iPad\n      Air, etc.\n\n  Returns:\n    a string, the last supported version.\n\n  Raises:\n    ios_errors.SimError: when there is no supported OS version of the given OS.\n    ios_errors.IllegalArgumentError: when the supported OS version can not match\n        the given simulator type.\n  '
    supported_os_versions = GetSupportedSimOsVersions(os_type)
    if (not supported_os_versions):
        raise ios_errors.SimError(('Can not find supported OS version of %s.' % os_type))
    if (not device_type):
        return supported_os_versions[(- 1)]
    simtype_max_os_version_float = float(simtype_profile.SimTypeProfile(device_type).max_os_version)
    supported_os_versions.reverse()
    for os_version in supported_os_versions:
        if (float(os_version) <= simtype_max_os_version_float):
            return os_version
    if (not supported_os_versions):
        raise ios_errors.IllegalArgumentError(('The supported OS version %s can not match simulator type %s. Because its max OS version is %s' % (supported_os_versions, device_type, simtype_max_os_version_float)))