xcode - 找不到 iPhone 6(或任何其他)模拟器 React-Native,没有什么帮助?
问题描述
无法使用 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. * 保留所有权利。* * 此源代码在此源代码树根目录中的 * LICENSE 文件中的 BSD 样式许可下获得许可。可以在同一目录中的 PATENTS 文件中找到额外授予的专利权。* */ 'use strict';
/** * 接受解析的模拟器列表和所需的名称,并返回一个具有匹配模拟器的对象。* * 如果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 指定为“不可用”</p>
解决方案
更改此行:
if (version.indexOf('iOS') !== 0) {
对此:
if (version.indexOf('com.apple.CoreSimulator.SimRuntime.iOS') !== 0) {
最近对 xcode 进行了更改,模拟器名称现在带有前缀。这为我解决了。
推荐阅读
- python - 在python的嵌套组列表中仅执行最终命令单击
- node.js - 此处出错 TypeError [ERR_INVALID_ARG_TYPE]:“路径”参数必须是字符串类型。接收到的类型对象
- javascript - 有没有办法在 javascript/JSX(React 框架)中使用字符串来引用常量
- ios - 新版本的 iOS 更改分发类型
- tensorflow - 如何在具有 TensorFlow Probability 的自定义函数上使用 MCMC 采样
- node.js - 在 node.js 中将文件上传到 Google Cloud Storage 时出错
- reactjs - 在 useEffect 中的酶/玩笑中测试事件监听器
- square-connect - Square Connect API:如何识别付款有任何争议
- stata - 使用Stata中的并行列表生成新变量
- r - 在r中的值限制内提取点周围的单元格