反应本机环境信息:
系统:
作业系统:macOS 10.14.2
中央处理器:(12)x64 Intel(R)Core(TM)i9-8950HK CPU @ 2.90GHz
内存:6.76 GB / 32.00 GB
外壳:3.2.57-/ bin / bash
二进制文件:
节点:10.15.0-/ usr / local / bin / node
纱线:1.13.0-/ usr / local / bin / yarn
npm:6.4.1-/ usr / local / bin / npm
SDK:
iOS SDK:
平台:iOS 12.1,macOS 10.14,tvOS 12.1,watchOS 5.1
IDE:
Android Studio:3.1 AI-173.4819257
Xcode:10.1 / 10B61-/ usr / bin / xcodebuild
npmPackages:
反应:16.6.3 => 16.6.3
反应本机:0.57.8 => 0.57.8
npmGlobalPackages:
create-react-native-app:1.0.0
react-native-cli:2.0.1
react-native-git-upgrade:0.2.7
我一直面临着一个问题,即无论我添加到--simulator参数中的模拟器如何,“ react-native run-ios”都无法启动。
XCode具有“命令行工具”的正确位置
我总是收到错误:
找不到iPhone X模拟器
Error: Could not find iPhone X simulator
at resolve (/Users/eric/.../swim/node_modules/react-native/local-cli/runIOS/runIOS.js:149:13)
at new Promise (<anonymous>)
at runOnSimulator (/Users/eric/.../swim/node_modules/react-native/local-cli/runIOS/runIOS.js:134:10)
at Object.runIOS [as func] (/Users/eric/.../swim/node_modules/react-native/local-cli/runIOS/runIOS.js:106:12)
at Promise.resolve.then (/Users/eric/.../swim/node_modules/react-native/local-cli/cliEntry.js:117:22)
从头开始安装XCode。
全新的“反应本机新应用”
不管--simulator选项如何,“ react-native run-ios”总是抱怨找不到模拟器。
我的临时解决方法是更改:
/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
第42行:
如果(!version.startsWith(' com.apple.CoreSimulator.SimRuntime.iOS ')&&!version.startsWith('tvOS')){
您似乎正在使用旧版本的React Native。 请更新到最新版本v0.58,然后验证问题是否仍然存在。
一旦您编辑了原始帖子,并在使用最新版本的项目上运行react-native info
,结果将自动删除“分辨率:旧版本”标签。
刚刚尝试了以下全新项目:
反应本机:0.58.3 => 0.58.3
和同样的问题
react-native run-ios —device=“XXXXXX’
传递要定位的模拟器我在这里也有同样的问题。
当我改变为
如果(!version.includes('iOS')&&!version.includes('tvOS')){
继续;
}
一切都很好,因为有前缀“ com.apple.CoreSimulator.SimRuntime”。 包含在设备列表中,对所有模拟器的startsWith进行纯检查都会失败。
嘿@osunnarvik感谢您创建PR! 您能否再解释一下(也许在PR中)为什么现在会发生这种情况? 我的意思是,前缀何时更改? 在最新的Xcode中? 🤔
我现在更新了PR的描述,以说说它何时开始发生,并添加了XCode和xcrun的一些版本信息。
@kelset是的,我相信设备列表的格式已随着最新的XCode更改。
太棒了-谢谢大家:)
我们已经将PR合并到0.58(因为0.59等将分隔CLI),并且下一个修补程序版本(0.58.4)将具有修复fix
@kelset我注意到https://github.com/react-native-community/react-native-cli/pull/138中有关您指定模拟器字符串的评论(来自
嗯,是的,在设置字符串时也最好进行检查。 🤔
好的,明天早上我去看看。
我创建了https://github.com/facebook/react-native/pull/23305来处理模拟器字符串的虚线输入版本
@osunnarvik此问题在react-native版本0.59.1中仍然存在
在以下行的node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
的模拟器版本中执行字符串搜索时遇到问题: if (!version.startsWith('iOS')
。
我将其替换为includes
,例如: if (!version.includes('iOS')
似乎已经为我解决了这个问题。
在以下行的
node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
的模拟器版本中执行字符串搜索时遇到问题:if (!version.startsWith('iOS')
。我将其替换为
includes
,例如:if (!version.includes('iOS')
似乎已经为我解决了这个问题。
它对我有用。谢谢。
在以下行的
node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
的模拟器版本中执行字符串搜索时遇到问题:if (!version.startsWith('iOS')
。我将其替换为
includes
,例如:if (!version.includes('iOS')
似乎已经为我解决了这个问题。
太好了,谢谢 !!
在以下行的
node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
的模拟器版本中执行字符串搜索时遇到问题:if (!version.startsWith('iOS')
。我将其替换为
includes
,例如:if (!version.includes('iOS')
似乎已经为我解决了这个问题。
我真的不明白这种情况是怎么存在的
新版本可以解决此问题吗?
@evanoralph如果今天像我一样遇到这个问题,您可以尝试在node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
修改findMatchingSimulator.js
node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
。
首先启动一个模拟器,然后运行xcrun simctl list --json devices
并使用"state" : "Booted",
搜索一个。
然后在findMatchingSimulator
函数的顶部添加:
return {
udid: <uuid from booted device>,
name: <Name of the booted simulator>,
booted: true,
version: "com.apple.CoreSimulator.SimRuntime.iOS-12-2",
}
version
可能有所不同。 但这是已引导设备对象的父键。 但这不是解决方法! 这是一种解决方法。
在以下行的
node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
的模拟器版本中执行字符串搜索时遇到问题:if (!version.startsWith('iOS')
。我将其替换为
includes
,例如:if (!version.includes('iOS')
似乎已经为我解决了这个问题。
更新至macOS 10.14.4,将XCode更新至10.2,此问题开始出现在我身上。 您的解决方案有所帮助(即使这只是临时解决方案)。
在以下行的
node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
的模拟器版本中执行字符串搜索时遇到问题:if (!version.startsWith('iOS')
。我将其替换为
includes
,例如:if (!version.includes('iOS')
似乎已经为我解决了这个问题。
太棒了! 虽然是暂时的,但运作良好。 谢谢!
在以下行的
node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
的模拟器版本中执行字符串搜索时遇到问题:if (!version.startsWith('iOS')
。我将其替换为
includes
,例如:if (!version.includes('iOS')
似乎已经为我解决了这个问题。
为我工作! 谢谢! 如果您运行的模拟器具有多个版本(例如iPhone 5s iOS 10.3.1和12.2),则此修复程序将打开所有模拟器版本。 您可以使用--simulator "iPhone 5s (10.3)"
定义版本。
@evanoralph如果今天像我一样遇到这个问题,您可以尝试在
node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
修改findMatchingSimulator.js
node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
。
首先启动一个模拟器,然后运行xcrun simctl list --json devices
并使用"state" : "Booted",
搜索一个。
然后在findMatchingSimulator
函数的顶部添加:return { udid: <uuid from booted device>, name: <Name of the booted simulator>, booted: true, version: "com.apple.CoreSimulator.SimRuntime.iOS-12-2", }
version
可能有所不同。 但这是已引导设备对象的父键。 但这不是解决方法! 这是一种解决方法。
解决方法现在对我来说很好,我不知道是否必须将项目更新到.59.0
我是唯一一个没有node_modules / react-native / local-cli / runIOS / findMatchingSimulator.js的人吗? local-cli文件夹中只有一件事,即cli.js文件-有什么想法吗?
仅供参考,在我的系统上出现以下问题似乎也有帮助:
xcrun simctl删除不可用
我遇到了问题,将其替换为includes
帮助我。 什么时候会修复?
HHHEEEYYYY ...替换包括工程!
@Titozzz关于何时
如果有人告诉我如何进行,我准备贡献自己的力量。
@Titozzz @kelset
我调查了我的问题,发现这是OP在这里提出的另一个问题。
问题是我需要在iPad上运行我的应用程序,并且因为iPad名称在括号中带有设备大小,例如。 iPad Pro (9.7-inch)
,cli代码假定括号中的设备大小为iOS运行时版本。
我建议我们为运行时ios版本使用一个单独的参数,或者为检测运行时版本使用不同的括号类型。
我的RN版本是0.59.3
您好,您可以回答问题吗?
我是唯一一个没有node_modules / react-native / local-cli / runIOS / findMatchingSimulator.js的人吗? local-cli文件夹中只有一件事,即cli.js文件-有什么想法吗?
@lpfunding此处: node_modules/@react-native-community/cli/build/commands/runIOS/findMatchingSimulator.js
很高兴您能看到我的消息! 其次,非常感谢您的答复! 但是我的Xcode是8.1版,除X之外我还有Xcode模拟器,但是当我编译时,终端错误找不到任何模拟器! 我在许多地方更改了编译条件,但无法解决问题,因此我留言了寻求帮助。
这是事实上的解决方法吗? 还是有公开的公关?
这对我来说是0.58.6。 看起来它已在提交9a8c9596ebe41e27d37ba18d6bf09f1c931c1ff2中修复
当您将react-native升级到v59时,此功能有效
我认为我的问题可能与以下事实有关:如果您使用的是XCode 10.2.1(就像我一样),苹果将iPhone XR模拟器重命名为iPhoneXʀ(请注意,大“ R”与小“ʀ”)因此,如果您要定位的是新近重命名的模拟器,请使用react-native run-ios --simulator="iPhone Xʀ"
。 谢谢苹果...
@ lcastillo88哦,哇,真是太好了,真是个奇怪的变化😅
对于因尝试运行iPad Pro模拟器而为此而苦苦挣扎的任何人,问题在于findMatchingSimulator.js
认为括号内的任何内容都是您尝试运行的模拟器的iOS版本。 因此,它正在尝试使用iOS版本10.5-inch
(或您要运行的任何模拟器)打开iPad Pro
模拟器。 由于明显的原因,这是行不通的。
在实施永久修复之前,最简单的解决方法是将模拟器重命名为不包含括号的名称。 在Xcode中,单击“窗口”>“设备和模拟器”,单击“模拟器”选项卡,然后右键单击正在使用的模拟器以对其重命名。
对于无法升级RN但需要更自动修复的任何人,可以在安装后使用以下shell脚本:
sed -i '' 's/startsWith/includes/g' node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
这帮助我们能够在CI服务器上执行自动化测试。
只是要确保我没有错过任何内容:如果您的评分为0.59,则此问题已解决,对吗?
特别是对于iPad Pro模拟器(或任何其他括号中包含iOS版本以外的模拟器),在最新版本的react-native上仍然无法解决。
除了这种情况,它工作正常。
在以下行的
node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
的模拟器版本中执行字符串搜索时遇到问题:if (!version.startsWith('iOS')
。我将其替换为
includes
,例如:if (!version.includes('iOS')
似乎已经为我解决了这个问题。
令人难以置信的,谢谢
如果有人需要在指定的iOS版本中运行:
react-native run-ios --simulator="iPhone 8 (12-0)"
之前是(12.0)
,但在我将xcode更新为10.2.1
之后更改为12-0
10.2.1
在以下行的
node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
的模拟器版本中执行字符串搜索时遇到问题:if (!version.startsWith('iOS')
。我将其替换为
includes
,例如:if (!version.includes('iOS')
似乎已经为我解决了这个问题。
这对我有用。谢谢
但是你能解释一下我的问题吗
@kelset
只是要确保我没有错过任何内容:如果您的评分为0.59,则此问题已解决,对吗?
我刚刚升级到0.59.8,它可以[通过react-native-git-upgrade
升级]
对于无法升级RN但需要更自动修复的任何人,可以在安装后使用以下shell脚本:
sed -i '' 's/startsWith/includes/g' node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
这帮助我们能够在CI服务器上执行自动化测试。
这对我有用
这可能会让我对仍然有用的人有所帮助
“本机”:“ 0.52.1”
我通过以下更改修复了此问题。
转到此路径。
node_modules / react-native / local-cli / runIOS / findMatchingSimulator.js
更改(我的行号是30 )
if (version.indexOf('iOS') !== 0)
至if (version.indexOf('iOS') === -1)
我正在使用[email protected]并且--simulator =“ iPhone 8”未正确解析。 添加控制台日志时,它似乎被解析为“ iPhone(不带引号)。我将node_modules / react-native / local-cli / runIOS / findMatchingSimulator.js更改为接受带有下划线的模拟器名称,以代替任何空格。
这似乎解决了我所看到的解析问题:
$ react-native run-ios --simulator =“ iPhone_8”
我在本地进行了以下更改:
函数findMatchingSimulator(simulators,simulatorString){
如果(!simulators.devices){
返回null;
}
const devices = Simulators.devices;
仿真器字符串=仿真器字符串.replace('_','')
今天,我已将其修复为runIOS/findMatchingSimulator.js
。 🎉我换了线if (simulator.availability !== '(available)' && simulator.isAvailable !== 'YES') {
至
if (simulator.availability !== '(available)' && simulator.isAvailable !== true) {
。
似乎isAvailable
属性返回常规布尔值,而不是设备列表中的YES
/ NO
。
顺便说一句,在安装Xcode 11 Beta之后,我遇到了这个问题。
react-native-cli:2.0.1
反应本机:0.59.9
遇到无法找到模拟器的相同错误。
原因:运行react-native run-ios时,默认模拟器名称为iPhoneX,根本不存在。 iPhoneX的名称是iPhoneXs,iPhoneXs Max或iPhoneXR
解决方案:修改node_modules/@react-native-community/cli/build/commands/runIOS/findMatchingSimulator.js中的代码
// change this line
// it was if (simulator.name ===simulatorName && !match) {
if (simulator.name.includes(simulatorName) && !match) {
match = {
udid: simulator.udid,
name: simulator.name,
booted,
version
};
} // Keeps track of the first available simulator for use if we can't find one above.
我的项目仍使用“ react-native”:“ 0.53.3”,对我来说,react-native node_modules文件夹中“ findMatchingSimulator.js”中的代码是
if (version.indexOf('iOS') != 0) {
continue;
}
不敢相信。
我在这里也有同样的问题。
当我改变为
如果(!version.includes('iOS')&&!version.includes('tvOS')){
继续;
}一切都很好,因为有前缀“ com.apple.CoreSimulator.SimRuntime”。 包含在设备列表中,对所有模拟器的startsWith进行纯检查都会失败。
谢谢它为我工作
我在这里也有同样的问题。
当我改变为
如果(!version.includes('iOS')&&!version.includes('tvOS')){
继续;
}一切都很好,因为有前缀“ com.apple.CoreSimulator.SimRuntime”。 包含在设备列表中,对所有模拟器的startsWith进行纯检查都会失败。
嗨,我的node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
不存在
@ topik96在这里检查。
node_modules/@react-native-community/cli/build/commands/runIOS/findMatchingSimulator.js
注意:以上修复程序对我不起作用。 我做了什么:
xcrun simctl list devices
react-native run-ios --simulator='iPad Pro (9.7-inch) (12.2)
。 注意iOS版本。以前,我在run命令中没有提到iOS版本。
现在检查可用的模拟器应该是:
仿真器.isAvailable!== true
我认为我的问题可能与以下事实有关:如果您使用的是XCode 10.2.1(就像我一样),苹果将iPhone XR模拟器重命名为iPhoneXʀ(请注意,大“ R”与小“ʀ”)因此,如果您要定位的是新近重命名的模拟器,请使用
react-native run-ios --simulator="iPhone Xʀ"
。 谢谢苹果...
为我工作。 谢谢。
我在这里也有同样的问题。
当我改变为
如果(!version.includes('iOS')&&!version.includes('tvOS')){
继续;
}一切都很好,因为有前缀“ com.apple.CoreSimulator.SimRuntime”。 包含在设备列表中,对所有模拟器的startsWith进行纯检查都会失败。
谢谢!为我工作!
我在这里也有同样的问题。
当我改变为
如果(!version.includes('iOS')&&!version.includes('tvOS')){
继续;
}
一切都很好,因为有前缀“ com.apple.CoreSimulator.SimRuntime”。 包含在设备列表中,对所有模拟器的startsWith进行纯检查都会失败。嗨,我的
node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
不存在
如果您在React Native的更新版本上使用新的cli,则会在这里找到它:
node_modules/@react-native-community/cli/build/commands/runIOS/findMatchingSimulator.js
今天,我已将其修复为
runIOS/findMatchingSimulator.js
。 🎉我换了线if (simulator.availability !== '(available)' && simulator.isAvailable !== 'YES') {
至
if (simulator.availability !== '(available)' && simulator.isAvailable !== true) {
。
似乎isAvailable
属性返回常规布尔值,而不是设备列表中的YES
/NO
。
顺便说一句,在安装Xcode 11 Beta之后,我遇到了这个问题。
我也安装了11 Beta。 它认为此脚本应同时检查YES
和true
吗?
无法解决问题,因此需要快速解决方案,因此我绕开了一个快速修复程序。
console.log设备,并破解了返回
在findMatchingSimulator.js
就在if(match) {return match}
我对退货进行了硬编码
return {
udid: 'BFBD0FA0-3104-4401-80BE-DC54CD7E3895',
name: 'iPhone X',
version: 'com.apple.CoreSimulator.SimRuntime.iOS-12-4'
}
我在这里也有同样的问题。
当我改变为
如果(!version.includes('iOS')&&!version.includes('tvOS')){
继续;
}一切都很好,因为有前缀“ com.apple.CoreSimulator.SimRuntime”。 包含在设备列表中,对所有模拟器的startsWith进行纯检查都会失败。
太棒了这就像一个魅力。 谢谢!
如果看到此错误:
error Could not find "iPhone X" simulator. Run CLI with --verbose flag for more details.
有关此简单解决方案,请参见我的评论:
sed -i'''s / startsWith / includes / g'node_modules / react-native / local-cli / runIOS / findMatchingSimulator.js
为我修复。
为我执行以下步骤修复
反应本机:0.52.3
打开文件
代码./node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
替换version.indexOf('iOS')!== 0
到!version.includes('iOS')
在过去的4个月中,在RN的服务器版本中,此问题一直在发生。 通常在进行某种更新后。 每次都会伤害我的生产力。
嗨,吉姆,您是否确认您在RN项目中没有RN项目(文件
系统明智)? 如果这样做,请尝试为每个文件夹创建一个项目。 这是什么
发生在我身上,一旦我将第二个项目删除到一个独立的文件夹中
(通过使用RN init)。 希望它能对您有所帮助:)
2019年9月21日星期六,18:28吉姆·霍尔[email protected]写道:
在过去的4个月中,这个问题一直在我身上发生
和RN的服务器版本上。 通常在进行某种更新后。 它
每次都会伤害我的生产力。-
您收到此邮件是因为您发表了评论。
直接回复此电子邮件,在GitHub上查看
https://github.com/facebook/react-native/issues/23282?
或使线程静音
https://github.com/notifications/unsubscribe-auth/ADA33H56N5ML47724MTTPFTQKY4TLANCNFSM4GUBJ5DQ
。
不再支持iPhone X模拟器吗? 我遇到了这个问题,并通过运行解决了-simulator="iPhone 11 Pro"
确认@ reza-hashemi的观察结果,在安装了Xcode 11.0(11A420a)的情况下运行instruments -s devices
不再列出iPhoneX。使用--simulator
标志提供其他模拟器是可行的。
看起来新版本的xCode默认没有添加iPhone X模拟器。 您还可以暂时通过在xCode中添加模拟器来解决此问题。 最终,应该可以将CLI更新为使用iPhone 11。
升级到Xcode 11后,出现错误
“找不到“ iPhone X”模拟器。”
容易修复...
Xcode->首选项->组件安装iOS 12.2汇总器
@broros步骤为我解决了这一问题。 XCode升级后开始出现此问题,但是,一旦经过模拟器,我将收到其他错误消息
error: Multiple commands produce '/ios/build/Debug-iphonesimulator/mobile.app/Zocial.ttf':
1) Target 'mobile' (project 'mobile') has copy command from '/node_modules/react-native-vector-icons/Fonts/Zocial.ttf' to '/mobile/ios/build/Debug-iphonesimulator/mobile.app/Zocial.ttf'
2) That command depends on command in Target 'mobile' (project 'mobile'): script phase “[CP] Copy Pods Resources”
要解决第二组错误,我必须在Xcode-> File-> Workspace settings-> Build System->(设置为Legacy)中打开ios项目。
将Xcode从10升级到11后,我也收到“ iPhone X Simulator”错误。 我尝试了在此线程中找到的一些脚本,而其他脚本则无济于事。 如果终端中有警告,请尝试npm audit fix
。 为我解决了,我现在启动就没有问题了。
已更新为xcode11。找不到设备。
问题在于解释脚本用来查找已安装设备的xcrun simctl list --json devices
的输出。
进入findMatchingSimulator的代码。 在条件说明
if (
simulator.availability !== '(available)' &&
simulator.isAvailable !== 'YES'
) {
continue
}
添加了isAvailable的新形式(现在是普通布尔值):
if (
simulator.availability !== '(available)' &&
simulator.isAvailable !== 'YES' &&
simulator.isAvailable !== true
) {
continue
}
这样整理出来的东西。
已更新为xcode11。找不到设备。
问题在于解释脚本用来查找已安装设备的xcrun simctl list --json devices
的输出。
进入findMatchingSimulator的代码。 在条件说明if ( simulator.availability !== '(available)' && simulator.isAvailable !== 'YES' ) { continue }
添加了isAvailable的新形式(现在是普通布尔值):
if ( simulator.availability !== '(available)' && simulator.isAvailable !== 'YES' && simulator.isAvailable !== true ) { continue }
这样整理出来的东西。
你好您能解释一下,在哪里findMatchingSimulator?
谢谢@galkahana ,
对我有用。
@TchernyavskyDaniil,您可以在项目文件夹node_modules中找到该文件./node_modules/\@react-native-community/cli/build/commands/runIOS/findMatchingSimulator.js
谢谢@galkahana ,
对我有用。
@TchernyavskyDaniil,您可以在项目文件夹node_modules中找到该文件./node_modules/\@react-native-community/cli/build/commands/runIOS/findMatchingSimulator.js
你的意思是:
/ cli-platform-IOS / ...?
我找不到你的路(runIOS):C
RN 60.4
@TchernyavskyDaniil我正在RN 0.59.9上运行
您可以从项目文件夹中的命令行执行find . -iname findMatchingSimulator.js
吗?
如果在路径中找到@,则在其前面添加反斜杠,然后使用vim或其他编辑器将其打开。
@TchernyavskyDaniil我正在RN 0.59.9上运行
您可以从项目文件夹中的命令行执行find . -iname findMatchingSimulator.js
吗?
如果在路径中找到@,则在其前面添加反斜杠,然后使用vim或其他编辑器将其打开。
是的,
./node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/findMatchingSimulator.js
好吧,我会试试的
“找不到“ iPhone X”模拟器。”
不错:)
在XCode 11上收到此错误。上帝保佑软件更新!
您可以将您的@ react-native-community / cli更新为1.9.8 https://github.com/react-native-community/cli/pull/414#issuecomment -499483963
@maxkomarychev
react-native --version
react-native-cli: 2.0.1
react-native: 0.59.8
@maxkomarychev我正在使用@react-native-community/[email protected]
并遇到此问题。
@galkahana谢谢。 那行得通。 但是修改node_modules
是致命的黑客,应该避免。 应该为此提高公关
- 您可以检查计算机上安装了哪个iOS模拟器吗?
- 您始终可以通过
react-native run-ios —device=“XXXXXX’
传递要定位的模拟器
只需在xcode中安装iPhone X设备
最近的Xcode更新后出现了相同的错误,该更新添加了新的电话模拟器并删除了一些较旧的模拟器:
希望这可以帮助某人...
如果按照上述@dmurchie的步骤操作后仍然遇到错误,则可能还需要更新@react-native-community/cli
。
您可以按照以下步骤操作:
https://github.com/react-native-community/cli#updating -the-cli
已更新为xcode11。找不到设备。
问题在于解释脚本用来查找已安装设备的xcrun simctl list --json devices
的输出。
进入findMatchingSimulator的代码。 在条件说明if ( simulator.availability !== '(available)' && simulator.isAvailable !== 'YES' ) { continue }
添加了isAvailable的新形式(现在是普通布尔值):
if ( simulator.availability !== '(available)' && simulator.isAvailable !== 'YES' && simulator.isAvailable !== true ) { continue }
这样整理出来的东西。
太棒了这就像一个魅力。 谢啦
@TchernyavskyDaniil您可以节省我的时间。 非常感谢!
RN 0.58.3
Xcode 11
有这个问题。
请按照以下步骤解决此问题:
code ./node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
更换
Simulator.availability!=='(可用)'
至
Simulator.availability!=='(可用)'&&
Simulator.isAvailable!=='是'&&
仿真器.isAvailable!== true
react-native run-ios
xcrun simctl list devices
react-native run-ios --configuration Debug --simulator='Your simulator' --scheme 'Your Scheme'
react-native run-ios --configuration Debug --simulator='iPhone 11 Pro Max' --scheme 'HelloWorld'
对我有用的另一种选择。
# to find what simulators you have
xcrun simctl list
# to run a specific simulator
rn run-ios --simulator "iPhone 11"
已更新为xcode11。找不到设备。
问题在于解释脚本用来查找已安装设备的xcrun simctl list --json devices
的输出。
进入findMatchingSimulator的代码。 在条件说明if ( simulator.availability !== '(available)' && simulator.isAvailable !== 'YES' ) { continue }
添加了isAvailable的新形式(现在是普通布尔值):
if ( simulator.availability !== '(available)' && simulator.isAvailable !== 'YES' && simulator.isAvailable !== true ) { continue }
这样整理出来的东西。
对我来说有用。
谢啦!
大家好,
我找到了其他解决方案,但未更改node_modules目录中的任何源代码。
如果您需要任何屏幕截图,请告诉我。
顺便说一下,这是我在github中的第一条评论,恭喜我:)
谢谢。
@ilkinnamazov您能否发送解决方案的屏幕截图?
当您在ios文件夹中打开.xcodeproj文件时,它将启动Xcode IDE,您可以在其中选择特定的模拟器。
请参见下面的屏幕截图。
您可以从此列表中选择设备。
但是,如果您没有看到iPhone X,则可以轻松地将其添加到设备列表中。
如果您有任何问题,请通知我。
谢谢。
如果在XCode中添加iPhone X模拟器后无法正常工作
yarn
或npm install
如果在XCode中添加iPhone X模拟器后无法正常工作
- 删除node_modules
- 删除yarn.lock或package-lock.json
- 运行
yarn
或npm install
在某些情况下,删除锁定文件可能会出现问题。 小心点
如果您只想运行任何特定设备。 它可能在“模拟器”列表中丢失。 要添加设备,请执行以下步骤:
1)打开Xcode
2)按Command+Shift+2
将打开“设备和模拟器”选项。
3)转到模拟器选项卡,然后按左下角的+图标,然后添加iPhone X或所需的任何丢失的设备。
请尝试此解决方案。 它可能为您工作。
https://github.com/facebook/react-native/issues/24450#issuecomment -516760157
我发现这是最简单的
react-native run-ios --simulator "iPhone 11 Pro Max"
对我来说,这似乎不再是问题。 也许在此期间进行了一些修复?
@danielcampo升级CLI的
我必须将其添加到我的package.json中:
"@react-native-community/cli": "@^1.12.0",
因为某种原因,如果没有它,锁将不会升级粘贴1.11.2。
现在,它发现模拟器没有问题。
已更新为xcode11。找不到设备。
问题在于解释脚本用来查找已安装设备的xcrun simctl list --json devices
的输出。
进入findMatchingSimulator的代码。 在条件说明if ( simulator.availability !== '(available)' && simulator.isAvailable !== 'YES' ) { continue }
添加了isAvailable的新形式(现在是普通布尔值):
if ( simulator.availability !== '(available)' && simulator.isAvailable !== 'YES' && simulator.isAvailable !== true ) { continue }
这样整理出来的东西。
这对我有用! 谢了,兄弟们!
如果有人仍在寻找findMatchingSimulator.js
文件来手动编辑它,则当前可以在以下路径找到它:
node_modules/@react-native-community/cli/build/commands/runIOS/findMatchingSimulator.js
我希望这可以帮助某人!
还请记住在括号内传递IOS版本:
--simulator "iPhone 11 Pro Max (13.2)"
我有@kelvinlemus
react-native-cli: 2.0.1
react-native: 0.61.5
我想更改默认模拟器“ iPhone X”
我正在尝试运行react-native run-ios --simulator='iPhone XR'
或其他
但每次都推出iPhone X
最有用的评论
在以下行的
node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
的模拟器版本中执行字符串搜索时遇到问题:if (!version.startsWith('iOS')
。我将其替换为
includes
,例如:if (!version.includes('iOS')
似乎已经为我解决了这个问题。