Не удалось найти iPhone 6 (или любой другой) симулятор React-Native, ничего не помогает? - PullRequest
0 голосов
/ 01 апреля 2019

Невозможно запустить мой проект с помощью симулятора iOS

ВЫПУСК,

Не удалось найти симулятор iPhone 6 (или X или любого другого)

XCODE: 10.2
    react-native: 0.52
    react: ^16.0.0-alpha.12

Вот мои findMatchingSimulator.js из nodemodules/react-native/local-cli/runIOS:

/ ** * Авторские права (c) 2015-настоящее время, Facebook, Inc. * Все права защищены.* * Этот исходный код лицензирован в соответствии с лицензией в стиле BSD, которая находится в файле * LICENSE в корневом каталоге этого исходного дерева.Дополнительное предоставление * патентных прав можно найти в файле PATENTS в том же каталоге. * * / 'Use strict';

/ ** * Принимает проанализированный список симулятора и желаемое имя и возвращаетобъект с соответствующим симулятором.* * Если аргумент simulatorName имеет значение null, мы перейдем в режим по умолчанию и вернем текущий загруженный симулятор, или, если * none не загружен, он будет первым в списке.*

 * @param Object simulators a parsed list from `xcrun simctl list --json devices` command
 * @param String|null simulatorName the string with the name of desired simulator. If null, it will use the currently
 *        booted simulator, or if none are booted, the first in the list.
 * @returns {Object} {udid, name, version}
 */
function findMatchingSimulator(simulators, simulatorName) {
  if (!simulators.devices) {
    return null;
  }
  const devices = simulators.devices;
  var match;
  for (let version in devices) {
    // Making sure the version of the simulator is an iOS (Removes Apple Watch, etc)
    if (version.indexOf('iOS') !== 0) {
      continue;
    }
    for (let i in devices[version]) {
      let simulator = devices[version][i];
      // Skipping non-available simulator
      if (simulator.availability !== '(available)') {
        continue;
      }
      // If there is a booted simulator, we'll use that as instruments will not boot a second simulator
      if (simulator.state === 'Booted') {
        if (simulatorName !== null) {
          console.warn("We couldn't boot your defined simulator due to an already booted simulator. We are limited to one simulator launched at a time.");
        }
        return {
          udid: simulator.udid,
          name: simulator.name,
          version
        };
      }
      if (simulator.name === simulatorName && !match) {
        match = {
          udid: simulator.udid,
          name: simulator.name,
          version
        };
      }
      // Keeps track of the first available simulator for use if we can't find one above.
      if (simulatorName === null && !match) {
        match = {
          udid: simulator.udid,
          name: simulator.name,
          version
        };
      }
    }
  }
  if (match) {
    return match;
  }
  return null;
}

module.exports = findMatchingSimulator;

Я пробовал разные методы, но ничего не помогает.В списке доступных устройств iPhone указан как «недоступный»

1 Ответ

5 голосов
/ 03 апреля 2019

Изменить эту строку:

if (version.indexOf('iOS') !== 0) {

к этому:

if (version.indexOf('com.apple.CoreSimulator.SimRuntime.iOS') !== 0) {

Недавно в xcode было внесено изменение, и теперь имена симуляторов имеют префикс. Это решило это для меня.

...