启动模拟器时 xcodebuild 超时

Eri*_*ler 7 teamcity xcodebuild codesign ios-simulator xcode8

我正在尝试使用 TeamCity 为我的 iOS 应用程序设置自动化测试。目前,我的代理正在构建,但是一旦构建了最后一个目标并运行 codesign,它就会挂起并显示以下内容:

[19:29:34][CodeSign] CodeSign /var/root/Library/Developer/Xcode/DerivedData/MyProductiOS-fgkoogiimhlbckdlbckzmqfyaoff/Build/Products/Debug-iphonesimulator/MyProductiOSUITests-Runner.app/PlugIns/MyProductiOSUITests.xctest
[19:29:34][CodeSign]     cd /Users/ericmiller/.tcagent/work/f9abef315a0137d4
[19:29:34][CodeSign]     export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
[19:29:34][CodeSign]     export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/ericmiller/.pyenv/shims:/Users/ericmiller/.rbenv/shims:/Users/ericmiller/.pyenv/shims:/Users/ericmiller/Scripts:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/opt/local/bin"
[19:29:34][CodeSign] Signing Identity:     "-"
[19:29:34][CodeSign]     /usr/bin/codesign --force --sign - --timestamp=none /var/root/Library/Developer/Xcode/DerivedData/MyProductiOS-fgkoogiimhlbckdlbckzmqfyaoff/Build/Products/Debug-iphonesimulator/MyProductiOSUITests-Runner.app/PlugIns/MyProductiOSUITests.xctest
[19:29:34][CodeSign] /var/root/Library/Developer/Xcode/DerivedData/MyProductiOS-fgkoogiimhlbckdlbckzmqfyaoff/Build/Products/Debug-iphonesimulator/MyProductiOSUITests-Runner.app/PlugIns/MyProductiOSUITests.xctest: replacing existing signature
[19:31:32][CodeSign] 2017-01-22 19:31:32.279 xcodebuild[28262:86807]  iOSSimulator: Timed out waiting 120 seconds for simulator to boot, current state is 1.
[19:31:32][CodeSign] 2017-01-22 19:31:32.290 xcodebuild[28262:86805]  iOSSimulator: Timed out waiting 120 seconds for simulator to boot, current state is 1.
[19:31:32][CodeSign] 2017-01-22 19:31:32.291 xcodebuild[28262:86797] Error Domain=IDETestOperationsObserverErrorDomain Code=3 "Timed out waiting 120 seconds for simulator to boot, current state is 1. If you believe this error represents a bug, please attach the log file at /var/root/Library/Developer/Xcode/DerivedData/MyProductiOS-fgkoogiimhlbckdlbckzmqfyaoff/Logs/Test/89F7C786-9E91-419F-98CA-F36385618DC2/Session-MyProductiOSTests-2017-01-22_192932-E95vcV.log" UserInfo={NSLocalizedDescription=Timed out waiting 120 seconds for simulator to boot, current state is 1. If you believe this error represents a bug, please attach the log file at /var/root/Library/Developer/Xcode/DerivedData/MyProductiOS-fgkoogiimhlbckdlbckzmqfyaoff/Logs/Test/89F7C786-9E91-419F-98CA-F36385618DC2/Session-MyProductiOSTests-2017-01-22_192932-E95vcV.log}
[19:31:32][CodeSign] 2017-01-22 19:31:32.291 xcodebuild[28262:86797] Error Domain=IDETestOperationsObserverErrorDomain Code=3 "Timed out waiting 120 seconds for simulator to boot, current state is 1. If you believe this error represents a bug, please attach the log file at /var/root/Library/Developer/Xcode/DerivedData/MyProductiOS-fgkoogiimhlbckdlbckzmqfyaoff/Logs/Test/89F7C786-9E91-419F-98CA-F36385618DC2/Session-MyProductiOSUITests-2017-01-22_192932-mrX7wQ.log" UserInfo={NSLocalizedDescription=Timed out waiting 120 seconds for simulator to boot, current state is 1. If you believe this error represents a bug, please attach the log file at /var/root/Library/Developer/Xcode/DerivedData/MyProductiOS-fgkoogiimhlbckdlbckzmqfyaoff/Logs/Test/89F7C786-9E91-419F-98CA-F36385618DC2/Session-MyProductiOSUITests-2017-01-22_192932-mrX7wQ.log}
Run Code Online (Sandbox Code Playgroud)

模拟器应用程序在 Dock 中打开。单击模拟器什么也不做,但如果我右键单击并选择窗口,我可以看到模拟器确实在运行,但没有显示任何内容。例子

我正在寻找一种解决方法来测试我的代码,如果可能,无需切换到物理设备而不是模拟器。我怎样才能实现这个目标,我的配置可能有什么问题?

截屏

编辑:

Sven Driemecker 找到了解决方案。这是我的配置。在运行 xcodebuild 之前,我运行以下 shell 脚本以确保一个卫生的测试环境。

xcrun simctl shutdown %env.simulator_guid%
killall Simulator
killall com.apple.CoreSimulator.CoreSimulatorService
xcrun simctl erase %env.simulator_guid%
Run Code Online (Sandbox Code Playgroud)

然后,在运行 xcodebuild 时,添加以下选项:

-destination "id=%env.simulator_guid%"
Run Code Online (Sandbox Code Playgroud)

最后,清理一切:

xcrun simctl shutdown %env.simulator_guid%
killall Simulator
killall com.apple.CoreSimulator.CoreSimulatorService
Run Code Online (Sandbox Code Playgroud)

更新:这是我写的一篇关于如何为 XCode/iOS 设置基本 TeamCity CI的博客文章

Jay*_*ais 5

尝试从 Xcode 11.3.1 在模拟器中运行 iOS 应用程序时,我遇到了类似的错误。我发现重新选择虚拟硬件可以比本页提到的其他解决方案更快地解决这个问题。

当我在 Xcode 中收到“超时等待 Simulator.app 准备就绪”错误时,Simulator.app 通常已启动但未显示实际模拟器。选择Hardware > Device > [OS version] -> [Simulator Name]会导致模拟器出现并在下次运行尝试时成功启动我的应用程序。

  • 在 Xcode 11.4 中,模拟器菜单项已移至“文件 > 打开设备 > [操作系统版本] -> [模拟器名称]” (5认同)

Sve*_*ker 2

这看起来很奇怪,但简单地重置模拟器通常可以解决这个问题。我们经常在自己的 CI 系统上遇到同样的错误。

尝试模拟器菜单 -> 重置内容和设置,然后重新启动模拟器。

您可以在命令行上强制执行此操作,但我不会推荐它,因为它会显着减慢您的构建速度。