升级到Xcode 10后找不到iPhone 6模拟器
我更新到了Xcode 10,由于我这样做了,我无法在终端中使用命令升级到Xcode 10后找不到iPhone 6模拟器,xcode,react-native,Xcode,React Native,我更新到了Xcode 10,由于我这样做了,我无法在终端中使用命令react native run ios运行模拟器。我得到这个错误: 找不到iPhone 6模拟器 当我进入Xcode>Window>Devices and Simulator时,模拟器就在那里,当我进入xcrun simctl list Devices时,我也会看到模拟器的列表 我可以使用react native run ios--device和Xcode在手机上运行该应用程序,我尝试了多个应用程序,因此它不是该应用程序 当我转
react native run ios
运行模拟器。我得到这个错误:
找不到iPhone 6模拟器
当我进入Xcode>Window>Devices and Simulator时,模拟器就在那里,当我进入xcrun simctl list Devices
时,我也会看到模拟器的列表
我可以使用react native run ios--device
和Xcode在手机上运行该应用程序,我尝试了多个应用程序,因此它不是该应用程序
当我转到Xcode>Preferences>Locations时,在命令行工具中选择Xcode 10.0(10A255)
我尝试重新启动计算机,并删除和重新安装Xcode
有什么想法吗
以下是我的设置:
- MacOs High Sierra 10.13.6
- Xcode版本10.0
- react本机cli:2.0.1
- 反应本机:0.57.1
- 找到了解决我问题的方法。
您需要进入react native node模块中的
local cli/runIOS/findMatchingSimulator.js
,并将第37行更改为
if (
simulator.availability !== '(available)' &&
simulator.isAvailable !== 'YES'
) {`
有关react native github上的解决方案和问题的更多信息:我也有类似的问题。 反应本机-0.52.3,XCode-10.2 beta 2
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.includes('iOS')) {
continue;
}
[...]
}
}
- 打开文件:
node\u modules/react native/local cli/runIOS/findMatchingSimulator.js
- 检查您的设备版本是否正确,例如:第29行
console.log(版本)
- 将其与第30行中的条件进行比较:
if(version.indexOf('iOS')!==0){
com.apple.CoreSimulator.SimRuntime.watchOS-5-0 -1
com.apple.CoreSimulator.SimRuntime.tvOS-12-1 -1
com.apple.CoreSimulator.SimRuntime.tvOS-12-2 -1
在这种情况下,我的任何版本都不会返回true…如果您有
- 将
version.indexOf('iOS')!==0替换为
,它为我解决了这个问题!version.includes('iOS')
react native
中修复,因此您可以在package.json中更新包:
npm install -g npm-check-updates
ncu -u react-native
npm install
一个对我有效的选择 检查mac中安装的模拟器列表,使用
xcrun simctl list --json devices
在模拟器列表中,选择任何模拟器名称并按如下方式运行
react-native run-ios --simulator 'iPhone 6s'
希望这对您有用我访问了node_modules/react native/local cli/runIOS/findMatchingSimulator.js 我替换了:
if(version.indexOf('iOS')!==0)
与
if(!version.includes(“iOS”)
及
if(simulator.availability!=='(available)
与
如果(simulator.isAvailable!==true)
转到node\u modules/react native/local cli/runIOS/并在findMatchingSimulator.js中将第30行替换为
if (version.indexOf('com.apple.CoreSimulator.SimRuntime.iOS') !== 0) {
使用react-native版本
0.55.3
和XCode 10我必须做两次更改才能运行react-native运行ios
内部node\u模块/react native/local cli/runIOS/findMatchingSimulator.js
:
// Skipping non-available simulator
if (simulator.availability !== true) {
// Making sure the version of the simulator is an iOS or tvOS (Removes Apple Watch, etc)
if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {
到
// Skipping non-available simulator
if (simulator.availability !== true) {
// Making sure the version of the simulator is an iOS or tvOS (Removes Apple Watch, etc)
if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {
到
可以通过修复下面的文件来解决此问题
/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
更换这条线
if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {
与
我只想和你们分享我是如何修复它的,也许它可以帮助别人 编辑此文件:node_modules/react native/local cli/runIOS/findMatchingSimulator.js 更改:
if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {
continue;
}
致:
这对我有用
我使用console.log(version)查看从变量version中得到的信息,该值不是预期的值。从package.json中删除这些行 “反应”:“XXXXXXXX”, “react native”:“yyyyyyyyyy” 然后跑 npm安装--保存反应本机反应
xcrun simctl list --json devices
自己编辑node\u模块/react native/local cli/runIOS/findMatchingSimulator.js
。
确保findMatchingSimulator
函数返回一个match
对象
{
udid: simulator.udid,
name: simulator.name,
version
}
我有一个自重构版本的findMatchingSimulator.js。如果将来有人仍面临此问题,而上述解决方案无法解决您的问题,只需覆盖…node_modules/react native/local cli/runIOS/findMatchingSimulator.js中的FindMatchingSimular方法 代码如下:
function findMatchingSimulator(simulators, simulatorName) {
if (!simulators.devices) {
return null;
}
const devices = simulators.devices;
var match = null;
for(let version in devices){
//Skip WatchOS
if(!version.includes("tvOS") && !version.includes("iOS")){
continue;
}
for(let d in devices[version]){
var currentDevice = devices[version][d];
if(!currentDevice.isAvailable){
continue;
}
if(currentDevice.state === "Booted" ){
let booted = currentDevice.state === "Booted";
if(currentDevice.name === simulatorName ){
return {
udid: currentDevice.udid,
name: currentDevice.name,
booted,
version,
};
}else if(!match){
//keep track of first available & bootable device
match = {
udid: currentDevice.udid,
name: currentDevice.name,
booted,
version,
};
}
}
}
}
if (match) {
return match;
}
return null;
}
}
编辑:这段代码将选择一个已经打开的模拟器,您仍然可以使用--simulator=“NAME”参数。可能它正在搜索具有不同iOS版本的模拟器?在尝试从命令行初始化时,同样的错误也会发生在我身上。在我的情况下,它会打开一个iPhone 6 iOS 8.1模拟器,但随后显示一条与您的一样的错误消息。(
找不到iPhone 6模拟器
)@JoseVf:在我这方面,它没有打开任何东西。我还尝试:-删除除iPhone 6之外的所有模拟器(在Xcode>Window>设备和模拟器中)并再次运行react native run ios
-使用新名称添加新模拟器-尝试使用
react native run ios打开模拟器--simulator=“iPhone 6”
Nothing works:(@JoseVf:在升级到Xcode 10后,您是否也遇到过这种情况?您是否在MacOs High Sierra 10.13.6?Xcode 10和MacOs Mojave(10.14),但也发生在High Sierra上。为了获得更高质量的响应,不仅要粘贴链接,还要解释一些操作,然后粘贴链接。如果链接断开,此响应将被废弃。@JoseVf:Updated;)这是/node\u modules/react native/local cli/runIOS/findMatchingSimulator.js,适用于不确定确切位置的任何人。现在应该是simulator.isAvailable!==true
Wow。这为我解决了问题。我将version.start('iOS')
更改为version.includes('iOS'))
这就解决了这个问题。Facebook React Native团队的QA通过了,这让我很惊讶。这也是我的问题,对我来说也很有用。Thanks@chenop它应该可以解决缺少iOS模拟器的问题,但是,升级react native可能会在您的应用程序中造成问题
{
udid: simulator.udid,
name: simulator.name,
version
}
function findMatchingSimulator(simulators, simulatorName) {
if (!simulators.devices) {
return null;
}
const devices = simulators.devices;
var match = null;
for(let version in devices){
//Skip WatchOS
if(!version.includes("tvOS") && !version.includes("iOS")){
continue;
}
for(let d in devices[version]){
var currentDevice = devices[version][d];
if(!currentDevice.isAvailable){
continue;
}
if(currentDevice.state === "Booted" ){
let booted = currentDevice.state === "Booted";
if(currentDevice.name === simulatorName ){
return {
udid: currentDevice.udid,
name: currentDevice.name,
booted,
version,
};
}else if(!match){
//keep track of first available & bootable device
match = {
udid: currentDevice.udid,
name: currentDevice.name,
booted,
version,
};
}
}
}
}
if (match) {
return match;
}
return null;
}
}