【问题标题】:Could not find iPhone 6(or any other) simulator React-Native, nothing helps?找不到 iPhone 6(或任何其他)模拟器 React-Native,没有什么帮助?
【发布时间】:2019-08-22 06:28:38
【问题描述】:

无法使用 iOS 模拟器运行我的项目

问题,

找不到 iPhone 6(或 X 或任何其他)模拟器

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

这是我来自nodemodules/react-native/local-cli/runIOS:findMatchingSimulator.js

/** * 版权所有 (c) 2015 年至今,Facebook, Inc. * 版权所有。 * * 此源代码是根据 BSD 风格的许可证获得许可的,可在 * 此源树根目录中的 LICENSE 文件。额外补助金 * 的专利权可以在同一目录下的 PATENTS 文件中找到。* */ '使用严格';

/** * 接受解析的模拟器列表和所需的名称,并返回具有匹配模拟器的对象。 * * 如果simulatorName 参数为null,我们将进入默认模式并返回当前启动的模拟器,或者如果 * 没有启动,它将是列表中的第一个。 *

 * @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 指定为“不可用”

【问题讨论】:

标签: xcode react-native simulator


【解决方案1】:

改变这一行:

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

到这里:

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

最近对 xcode 进行了更改,模拟器名称现在带有前缀。这为我解决了。

【讨论】:

    猜你喜欢
    • 2019-04-29
    • 2023-04-09
    • 2019-06-27
    • 2019-06-27
    • 2021-04-29
    • 1970-01-01
    • 2017-11-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多