【发布时间】: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 指定为“不可用”
【问题讨论】:
-
使用下面的脚本简单快速的解决方案。 stackoverflow.com/a/56920807/706888
标签: xcode react-native simulator