xcode iOS模拟器第一次启动需要很长时间

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33025054/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 08:01:13  来源:igfitidea点击:

iOS Simulator takes extremely long time to boot first time

iosxcodeios-simulatorxcode7

提问by Software2

I'm trying to run an iOS simulator (Xcode 7.0.1, OS X Yosemite). However, the first time I run the simulator, it takes a very long time to boot up (80-120 seconds), which is causing my automation testing to time out. If I close the simulator and re-launch the same one, it will boot up in about 5-8 seconds. Launching a different device will cause the long boot up time again.

我正在尝试运行 iOS 模拟器(Xcode 7.0.1、OS X Yosemite)。但是,我第一次运行模拟器时,启动需要很长时间(80-120 秒),这导致我的自动化测试超时。如果我关闭模拟器并重新启动相同的模拟器,它将在大约 5-8 秒内启动。启动不同的设备将再次导致较长的启动时间。

I have tried resetting the content and settings of the simulator, deleting and re-downloading simulators, and uninstalling and reinstalling Xcode.

我尝试过重置模拟器的内容和设置,删除并重新下载模拟器,以及卸载并重新安装Xcode。

This machine is a Parallels Desktop VM running on a 2012 Mac Mini. While I do not believe this to be a resource issue (the simulator runs just fine with the second launch), I have tried increasing ram and video memory to the VM with no success.

这台机器是在 2012 Mac Mini 上运行的 Parallels Desktop VM。虽然我不认为这是资源问题(模拟器在第二次启动时运行良好),但我尝试增加 VM 的内存和视频内存,但没有成功。

采纳答案by Software2

My solution so far has been to pre-boot the Simulator prior to needing it for automation. I consider this somewhat hackish, but it does get the job done.

到目前为止,我的解决方案是在需要自动化之前预启动模拟器。我认为这有点骇人听闻,但它确实完成了工作。

xcrun instruments -w "Simulator Name Here"
sleep 120

This will launch the simulator, then sleep for a couple minutes before proceeding on to whatever else you need the simulator for.

这将启动模拟器,然后睡眠几分钟,然后继续进行模拟器所需的任何其他操作。

回答by Denis

Had the same issue after updating to Xcode 7 on my iMac (late 2013). And yesterday I've succeeded to resolve it by doing 2 steps (unfortunately, I don't know which did really help):

在我的 iMac(2013 年末)上更新到 Xcode 7 后遇到了同样的问题。昨天我通过执行 2 个步骤成功解决了它(不幸的是,我不知道哪个确实有帮助):

  1. I had Xcode 6 installed side by side with Xcode 7. So I've deleted Xcode 6 instance.
  2. Open Xcode 7, go to Window -> Devices and delete all listed iOS simulators you have there. Close & re-start Xcode. Go to Window -> Devices again and add only simulators you need (in my case I've added iPhone 6 iOS 8, iPhone 6s iOS 9, iPad Air 2 iOS 9). You can add more simulators later on as you need them. Also, not sure if this is critical, I've selected no paired watchOS device for simulators I've added.
  1. 我将 Xcode 6 与 Xcode 7 并排安装。所以我删除了 Xcode 6 实例。
  2. 打开 Xcode 7,转到 Window -> Devices 并删除所有列出的 iOS 模拟器。关闭并重新启动 Xcode。再次转到 Window -> Devices 并仅添加您需要的模拟器(在我的情况下,我添加了 iPhone 6 iOS 8、iPhone 6s iOS 9、iPad Air 2 iOS 9)。您可以稍后根据需要添加更多模拟器。另外,不确定这是否重要,我没有为我添加的模拟器选择配对的 watchOS 设备。

After completing these steps, my simulator cold start was significantly imporoved - it takes now like 30-40seconds max for a cold start. Before that it was 3-4minutes and first debugger attach attempt always failed.

完成这些步骤后,我的模拟器冷启动得到了显着改善 - 现在冷启动最多需要 30-40 秒。在此之前是 3-4 分钟,第一次调试器附加尝试总是失败。

Hope, this will be helpful for somebody.

希望,这对某人有帮助。

回答by Jeremy Huddleston Sequoia

At first boot, the sim device will go through initial setup just like a real device. Taking 2 minutes is quite a long time on modern systems but not that unheard of, especially if you're not on an SSD. I suggest you watch the sim device's system.log to see what tasks are occurring during the boot process and keep an eye out for any errors that might indicate what is going wrong.

首次启动时,sim 设备将像真实设备一样进行初始设置。在现代系统上花费 2 分钟是相当长的时间,但并非闻所未闻,特别是如果您没有使用 SSD。我建议您查看 sim 设备的 system.log 以查看启动过程中正在发生的任务,并留意可能表明出现问题的任何错误。

回答by Fredrik Johansson

I tried to run the iPhone6S simulator on my Macbook Air, and it just hung at the game center login screen. It hung for 10 minutes. I had 50% scale on the simulator window. Then I tried to reduce the scale even more, and immediately it passed the GC login screen.

我试图在我的 Macbook Air 上运行 iPhone6S 模拟器,它只是挂在游戏中心登录屏幕上。它挂了10分钟。我在模拟器窗口上有 50% 的比例。然后我尝试进一步缩小规模,并立即通过了 GC 登录屏幕。

My guess is that my little Air has don't have time to do anything else but updating the simulator screen at high scales, and when I reduced the scale it had time to bother with the game center login functionality. My simulator widow is the size of a stamp now. :)

我的猜测是,我的小 Air 除了以高比例更新模拟器屏幕之外没有时间做任何其他事情,而当我缩小比例时,它有时间来处理游戏中心登录功能。我的模拟器寡妇现在只有邮票那么大。:)

Puh. I've had this simulator problem for weeks...

噗。我已经有这个模拟器问题好几个星期了...