def CreateNewSimulator(device_type=None, os_version=None, name_prefix=None):
    'Creates a new simulator according to arguments.\n\n  If neither device_type nor os_version is given, will use the latest iOS\n  version and latest iPhone type.\n  If os_version is given but device_type is not, will use latest iPhone type\n  according to the OS version limitation. E.g., if the given os_version is 9.3,\n  the latest simulator type is iPhone 6s Plus. Because the min OS version of\n  iPhone 7 is 10.0.\n  If device_type is given but os_version is not, will use the min value\n  between max OS version of the simulator type and current latest OS version.\n  E.g., if the given device_type is iPhone 5 and latest OS version is 10.3,\n  will use 10.2. Because the max OS version of iPhone 5 is 10.2.\n\n  Args:\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    os_version: string, OS version of the new simulator. The format is\n      {major}.{minor}, such as 9.3, 10.2.\n    name_prefix: string, name prefix of the new simulator. By default, it is\n      "New".\n\n  Returns:\n     a tuple with four items:\n        string, id of the new simulator.\n        string, simulator device type of the new simulator.\n        string, OS version of the new simulator.\n        string, name of the new simulator.\n\n  Raises:\n    ios_errors.SimError: when failed to create new simulator.\n    ios_errors.IllegalArgumentError: when the given argument is invalid.\n  '
    if (not device_type):
        os_type = ios_constants.OS.IOS
    else:
        _ValidateSimulatorType(device_type)
        os_type = GetOsType(device_type)
    if (not os_version):
        os_version = GetLastSupportedSimOsVersion(os_type, device_type=device_type)
    else:
        supported_sim_os_versions = GetSupportedSimOsVersions(os_type)
        if (os_version not in supported_sim_os_versions):
            raise ios_errors.IllegalArgumentError(('The simulator os version %s is not supported. Supported simulator os versions are %s.' % (os_version, supported_sim_os_versions)))
    if (not device_type):
        device_type = GetLastSupportedIphoneSimType(os_version)
    else:
        _ValidateSimulatorTypeWithOsVersion(device_type, os_version)
    if (not name_prefix):
        name_prefix = 'New'
    name = ('%s-%s-%s' % (name_prefix, device_type, os_version))
    runtime_id = (((_PREFIX_RUNTIME_ID + os_type) + '-') + os_version.replace('.', '-'))
    logging.info('Creating a new simulator:\nName: %s\nOS: %s %s\nType: %s', name, os_type, os_version, device_type)
    for i in range(0, _SIM_OPERATION_MAX_ATTEMPTS):
        try:
            new_simulator_id = RunSimctlCommand(['xcrun', 'simctl', 'create', name, device_type, runtime_id])
        except ios_errors.SimError as e:
            raise ios_errors.SimError(('Failed to create simulator: %s' % str(e)))
        new_simulator_obj = Simulator(new_simulator_id)
        try:
            new_simulator_obj.WaitUntilStateShutdown(_SIMULATOR_CREATING_TO_SHUTDOWN_TIMEOUT_SEC)
            logging.info('Created new simulator %s.', new_simulator_id)
            return (new_simulator_id, device_type, os_version, name)
        except ios_errors.SimError as error:
            logging.debug('Failed to create simulator %s: %s.', new_simulator_id, error)
            logging.debug('Deleted half-created simulator %s.', new_simulator_id)
            new_simulator_obj.Delete()
            if (i != (_SIM_OPERATION_MAX_ATTEMPTS - 1)):
                logging.debug('Will sleep %ss and retry again.', _SIM_ERROR_RETRY_INTERVAL_SEC)
                time.sleep(_SIM_ERROR_RETRY_INTERVAL_SEC)
    raise ios_errors.SimError(('Failed to create simulator in %d attempts.' % _SIM_OPERATION_MAX_ATTEMPTS))
Creates a new simulator according to arguments.

If neither device_type nor os_version is given, will use the latest iOS
version and latest iPhone type.
If os_version is given but device_type is not, will use latest iPhone type
according to the OS version limitation. E.g., if the given os_version is 9.3,
the latest simulator type is iPhone 6s Plus. Because the min OS version of
iPhone 7 is 10.0.
If device_type is given but os_version is not, will use the min value
between max OS version of the simulator type and current latest OS version.
E.g., if the given device_type is iPhone 5 and latest OS version is 10.3,
will use 10.2. Because the max OS version of iPhone 5 is 10.2.

Args:
  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.
  os_version: string, OS version of the new simulator. The format is
    {major}.{minor}, such as 9.3, 10.2.
  name_prefix: string, name prefix of the new simulator. By default, it is
    "New".

Returns:
   a tuple with four items:
      string, id of the new simulator.
      string, simulator device type of the new simulator.
      string, OS version of the new simulator.
      string, name of the new simulator.

Raises:
  ios_errors.SimError: when failed to create new simulator.
  ios_errors.IllegalArgumentError: when the given argument is invalid.
def CreateNewSimulator(device_type=None, os_version=None, name_prefix=None):
    'Creates a new simulator according to arguments.\n\n  If neither device_type nor os_version is given, will use the latest iOS\n  version and latest iPhone type.\n  If os_version is given but device_type is not, will use latest iPhone type\n  according to the OS version limitation. E.g., if the given os_version is 9.3,\n  the latest simulator type is iPhone 6s Plus. Because the min OS version of\n  iPhone 7 is 10.0.\n  If device_type is given but os_version is not, will use the min value\n  between max OS version of the simulator type and current latest OS version.\n  E.g., if the given device_type is iPhone 5 and latest OS version is 10.3,\n  will use 10.2. Because the max OS version of iPhone 5 is 10.2.\n\n  Args:\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    os_version: string, OS version of the new simulator. The format is\n      {major}.{minor}, such as 9.3, 10.2.\n    name_prefix: string, name prefix of the new simulator. By default, it is\n      "New".\n\n  Returns:\n     a tuple with four items:\n        string, id of the new simulator.\n        string, simulator device type of the new simulator.\n        string, OS version of the new simulator.\n        string, name of the new simulator.\n\n  Raises:\n    ios_errors.SimError: when failed to create new simulator.\n    ios_errors.IllegalArgumentError: when the given argument is invalid.\n  '
    if (not device_type):
        os_type = ios_constants.OS.IOS
    else:
        _ValidateSimulatorType(device_type)
        os_type = GetOsType(device_type)
    if (not os_version):
        os_version = GetLastSupportedSimOsVersion(os_type, device_type=device_type)
    else:
        supported_sim_os_versions = GetSupportedSimOsVersions(os_type)
        if (os_version not in supported_sim_os_versions):
            raise ios_errors.IllegalArgumentError(('The simulator os version %s is not supported. Supported simulator os versions are %s.' % (os_version, supported_sim_os_versions)))
    if (not device_type):
        device_type = GetLastSupportedIphoneSimType(os_version)
    else:
        _ValidateSimulatorTypeWithOsVersion(device_type, os_version)
    if (not name_prefix):
        name_prefix = 'New'
    name = ('%s-%s-%s' % (name_prefix, device_type, os_version))
    runtime_id = (((_PREFIX_RUNTIME_ID + os_type) + '-') + os_version.replace('.', '-'))
    logging.info('Creating a new simulator:\nName: %s\nOS: %s %s\nType: %s', name, os_type, os_version, device_type)
    for i in range(0, _SIM_OPERATION_MAX_ATTEMPTS):
        try:
            new_simulator_id = RunSimctlCommand(['xcrun', 'simctl', 'create', name, device_type, runtime_id])
        except ios_errors.SimError as e:
            raise ios_errors.SimError(('Failed to create simulator: %s' % str(e)))
        new_simulator_obj = Simulator(new_simulator_id)
        try:
            new_simulator_obj.WaitUntilStateShutdown(_SIMULATOR_CREATING_TO_SHUTDOWN_TIMEOUT_SEC)
            logging.info('Created new simulator %s.', new_simulator_id)
            return (new_simulator_id, device_type, os_version, name)
        except ios_errors.SimError as error:
            logging.debug('Failed to create simulator %s: %s.', new_simulator_id, error)
            logging.debug('Deleted half-created simulator %s.', new_simulator_id)
            new_simulator_obj.Delete()
            if (i != (_SIM_OPERATION_MAX_ATTEMPTS - 1)):
                logging.debug('Will sleep %ss and retry again.', _SIM_ERROR_RETRY_INTERVAL_SEC)
                time.sleep(_SIM_ERROR_RETRY_INTERVAL_SEC)
    raise ios_errors.SimError(('Failed to create simulator in %d attempts.' % _SIM_OPERATION_MAX_ATTEMPTS))