iOS 运行两个模拟器失败:无法在当前状态下查找:关机

Posted

技术标签:

【中文标题】iOS 运行两个模拟器失败:无法在当前状态下查找:关机【英文标题】:iOS run two simulators failed: Unable to lookup in current state: Shutdown 【发布时间】:2021-09-22 12:11:00 【问题描述】:

我正在尝试在更多模拟器上运行我的(React 本机)应用程序。

yarn run ios --simulator="iPhone SE"
# also tried
yarn run ios --simulator="iPhone SE (2nd generation)"

第一个模拟器成功启动,但另一个失败。

我有错误:

在当前状态下无法查找:关机

Xcode 版本:13.0,模拟器 操作系统版本:macOS Big Sur 11.5.2

success Successfully built the app
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
 platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device 
 platform:iOS Simulator, id:FDCE0C7E-5917-42BB-AD4E-FAAA3D726BEE, OS:13.5, name:iPhone 8 
 platform:iOS Simulator, id:1034D1B6-A0EF-4334-A4F8-C74E74B092E6, OS:15.0, name:iPhone 8 
 platform:iOS Simulator, id:93D44AD6-FB9A-4E8F-819E-52FFC9DD01F5, OS:13.5, name:iPhone 8 Plus 
 platform:iOS Simulator, id:3FB69956-5357-44CE-88EF-DF02A6930C1D, OS:15.0, name:iPhone 8 Plus 
 platform:iOS Simulator, id:3AEA5922-A5DE-4F26-9C41-056DD18DE33F, OS:13.5, name:iPhone 11 
 platform:iOS Simulator, id:C18F8CC6-6712-45EC-B10B-838CF1961B20, OS:15.0, name:iPhone 11 
 platform:iOS Simulator, id:6815E116-44A3-47C3-A454-82EF37C20BE5, OS:13.5, name:iPhone 11 Pro 
 platform:iOS Simulator, id:C095653C-0FD3-493C-B4E6-D65CEEDCE135, OS:15.0, name:iPhone 11 Pro 
 platform:iOS Simulator, id:BC6B4577-2A4B-43C8-B1F9-54B0755D3D19, OS:13.5, name:iPhone 11 Pro Max 
 platform:iOS Simulator, id:5180B3F4-3D40-487C-941B-F0A3A0B28570, OS:15.0, name:iPhone 11 Pro Max 
 platform:iOS Simulator, id:6D22A3E2-F0B7-40A6-9E30-05CB3837470D, OS:15.0, name:iPhone 12 
 platform:iOS Simulator, id:20AF9F18-024F-4242-9113-94BB855B1BA6, OS:15.0, name:iPhone 12 Pro 
 platform:iOS Simulator, id:639D955E-9BA8-4ECF-BA68-DC6C1F9CCD74, OS:15.0, name:iPhone 12 Pro Max 
 platform:iOS Simulator, id:612F66A0-7050-45D0-A46F-805E390AF074, OS:15.0, name:iPhone 12 mini 
 platform:iOS Simulator, id:0FE7C078-556D-40F9-8198-375C10B3991D, OS:15.0, name:iPhone 13 
 platform:iOS Simulator, id:885D1181-08F8-438A-8B9A-FE940BCCA59B, OS:15.0, name:iPhone 13 Pro 
 platform:iOS Simulator, id:5803C768-0E6F-420C-A236-0637CE433775, OS:15.0, name:iPhone 13 Pro Max 
 platform:iOS Simulator, id:8A9F4BC4-D751-4D25-8290-E3D35C46F48F, OS:15.0, name:iPhone 13 mini 
 platform:iOS Simulator, id:493495F3-2F78-4A60-B937-FDDA6A533282, OS:13.5, name:iPhone SE 
 platform:iOS Simulator, id:9731F210-9C16-43AB-AC99-22C2E55F1F86, OS:13.5, name:iPhone SE (2nd generation) 
 platform:iOS Simulator, id:6B410509-2517-4909-8174-F42CBEE974B8, OS:15.0, name:iPhone SE (2nd generation) 
 platform:iOS Simulator, id:D0C1C85A-C505-4902-ADCA-BA9408964D2C, OS:13.5, name:iPhone X 
 platform:iOS Simulator, id:CAF4BBDC-BEB9-4C23-B947-F1A0CE626012, OS:15.0, name:iPod touch (7th generation) 
 platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device 
 platform:iOS Simulator, id:9BF4625F-142F-427D-A9D1-8A831C62E63B, OS:13.5, name:iPad (7th generation) 
 platform:iOS Simulator, id:3745BC92-4688-4B75-9D92-25EF2FCC52DB, OS:15.0, name:iPad (9th generation) 
 platform:iOS Simulator, id:6AB2E356-D8D1-42A4-B2B7-BA18DCA7F543, OS:13.5, name:iPad Air (3rd generation) 
 platform:iOS Simulator, id:350A8457-97C3-440D-B521-BD9BD067F3CB, OS:15.0, name:iPad Air (4th generation) 
 platform:iOS Simulator, id:3FA72A11-0536-4BDC-B113-503D31731401, OS:13.5, name:iPad Pro (9.7-inch) 
 platform:iOS Simulator, id:67CD5DF7-5037-4B80-8711-8BD3692A18E9, OS:15.0, name:iPad Pro (9.7-inch) 
 platform:iOS Simulator, id:68CD4C92-AD3D-4F55-B258-E8FF6B557E8A, OS:13.5, name:iPad Pro (11-inch) (2nd generation) 
 platform:iOS Simulator, id:9ABE2EC3-245C-4189-AD56-13D8FC0D808E, OS:15.0, name:iPad Pro (11-inch) (3rd generation) 
 platform:iOS Simulator, id:CF04F4B8-6B81-4DC3-9FF0-0C5FE3465587, OS:13.5, name:iPad Pro (12.9-inch) (4th generation) 
 platform:iOS Simulator, id:F1B64316-868F-409B-8932-03A8570279B9, OS:15.0, name:iPad Pro (12.9-inch) (5th generation) 
 platform:iOS Simulator, id:D9D361CC-479C-4856-A560-699C5D1A91A1, OS:15.0, name:iPad mini (6th generation) 
info Installing "/Users/babu/Library/Developer/Xcode/DerivedData/MyApp-axbsjlkepgdnjucdpwvjpiaqcuef/Build/Products/Debug-iphonesimulator/MyApp.app"
An error was encountered processing the command (domain=com.apple.CoreSimulator.SimError, code=405):
Unable to lookup in current state: Shutdown
info Launching "org.myapp.ios.dev"
error Failed to launch the app on simulator, An error was encountered processing the command (domain=com.apple.CoreSimulator.SimError, code=405):
Unable to lookup in current state: Shutdown

【问题讨论】:

是的,也得到了这个,因为更新到 Xcode 13。我发现如果我打开simulator.app 然后文件-> 打开模拟器-> Iphone 13 Pro,让 sim 启动然后用 @ 启动 RN 987654323@它将启动 似乎是最新版本的 Xcode (13) 的问题。 【参考方案1】:

我在将 Xcode 更新到 13.0 版后遇到了这个问题,这是由于 Xcode 缓存造成的。您可以清除 DerivedData 文件夹来解决此问题

您可以尝试按照以下步骤解决问题:

    打开 Xode 并选择 Preferences > Locations。 1 打开首选项窗格后,单击/Xcode/DerivedData 旁边的箭头。这应该会打开一个查找器窗口。 2 删除 DerivedData 文件夹中的所有子目录 关闭 Xcode 并清理构建应用以安装在 iOS 设备上
yarn ios

这应该会自动启动 iPhone 模拟器并解决您的问题。如果不是,您也可以尝试删除 Xcode 进程:Build error domain=com.apple.CoreSimulator.SimError, code=405

【讨论】:

【参考方案2】:

tl;dr:通过模拟器工具手动启动第二个 sim,然后运行带有匹配 --simulator 标志的 run-ios 命令以定位您刚刚打开的 sim。

我尝试了 Ravi 的建议以及他链接的主题中的建议,以及他链接的主题中链接的 apple dev 主题中的建议,不知道为什么,但我自己仍在体验。

在我的情况下,当 sim 已经运行时尝试第二个 run-ios 命令会给我 OP 的错误。为了避免这个错误,我:

    通过:xcode -> open developer tool -> simulator -> file -> open simulator -> simName. 手动启动第二个 sim yarn run-ios 命令带有标志--simulator="simName".

(为确保您使用正确的 ios 版本指向正确的 sim,您可以通过以下方式为您的 sim 起一个描述性名称:xcode -> window -> devices & simulators -> simulators -> click a name on the left panel to rename)

【讨论】:

以上是关于iOS 运行两个模拟器失败:无法在当前状态下查找:关机的主要内容,如果未能解决你的问题,请参考以下文章

无法在当前状态下启动设备:正在创建

TestFlight 安装应用失败,无法删除部分安装的应用

无法在 iOS 模拟器上运行 Flutter 应用程序 / 命令 PhaseScriptExecution 失败,退出代码为非零

在较旧的 iOS 模拟器上运行时 Xcode 10 测试失败 - “无法加载测试包......找不到合适的图像”

Xcode 5 应用程序在 IOS 8 的已发布版本下无法运行

Xcode 9 模拟器无法运行