模拟器已打开时并行运行单元测试出现Could not launch Simulator.app错误
问题
串行运行所有测试均可通过;未启动模拟器时并行运行单元测试,所有测试也能通过。但选中6个及以上测试同时运行时,测试导航器显示测试通过,却弹出“Test failed”覆盖层和“Could not launch Simulator.app”的弹窗。推测是模拟器已启动导致的bug,但不清楚为何会导致测试失败,请问有人遇到过这类问题吗?
错误详情
详情 无法启动Simulator.app。 域:DVTiPhoneSimulatorErrorDomain 代码:1 用户信息:{ DVTErrorCreationDateKey = "2023-08-10 05:13:12 +0000"; IDERunOperationFailingWorker = IDELaunchiPhoneSimulatorLauncher; } -- 操作无法完成。(OSStatus错误 -600。) 域:NSOSStatusErrorDomain 代码:-600 -- 分析事件:com.apple.dt.IDERunOperationWorkerFinished : { "device_model" = "iPhone15,2"; "device_osBuild" = "16.4 (20E247)"; "device_platform" = "com.apple.platform.iphonesimulator"; "launchSession_schemeCommand" = Test; "launchSession_state" = 1; "launchSession_targetArch" = arm64; "operation_duration_ms" = 54; "operation_errorCode" = 1; "operation_errorDomain" = DVTiPhoneSimulatorErrorDomain; "operation_errorWorker" = IDELaunchiPhoneSimulatorLauncher; "operation_name" = IDERunOperationWorkerGroup; "param_consoleMode" = 0; "param_debugger_attachToExtensions" = 0; "param_debugger_attachToXPC" = 1; "param_debugger_type" = 3; "param_destination_isProxy" = 0; "param_destination_platform" = "com.apple.platform.iphonesimulator"; "param_diag_MainThreadChecker_stopOnIssue" = 0; "param_diag_MallocStackLogging_enableDuringAttach" = 0; "param_diag_MallocStackLogging_enableForXPC" = 0; "param_diag_allowLocationSimulation" = 1; "param_diag_checker_tpc_enable" = 0; "param_diag_gpu_frameCapture_enable" = 3; "param_diag_gpu_shaderValidation_enable" = 0; "param_diag_gpu_validation_enable" = 1; "param_diag_memoryGraphOnResourceException" = 0; "param_diag_queueDebugging_enable" = 1; "param_diag_runtimeProfile_generate" = 0; "param_diag_sanitizer_asan_enable" = 0; "param_diag_sanitizer_tsan_enable" = 0; "param_diag_sanitizer_tsan_stopOnIssue" = 0; "param_diag_sanitizer_ubsan_stopOnIssue" = 0; "param_diag_showNonLocalizedStrings" = 0; "param_diag_viewDebugging_enabled" = 1; "param_diag_viewDebugging_insertDylibOnLaunch" = 0; "param_install_style" = 0; "param_launcher_UID" = 2; "param_launcher_allowDeviceSensorReplayData" = 0; "param_launcher_kind" = 0; "param_launcher_style" = 0; "param_launcher_substyle" = 0; "param_runnable_appExtensionHostRunMode" = 0; "param_runnable_productType" = "com.apple.product-type.tool"; "param_testing_launchedForTesting" = 1; "param_testing_suppressSimulatorApp" = 0; "param_testing_usingCLI" = 0; "sdk_canonicalName" = "iphonesimulator16.4"; "sdk_osVersion" = "16.4"; "sdk_variant" = iphonesimulator; } -- 系统信息 macOS版本13.4.1(内部版本22F82) Xcode 14.3.1(21815)(内部版本14E300c) 时间戳:2023-08-10T13:13:12+08:00
解决思路
- 强制清理进程后重启:
在终端执行以下命令关闭模拟器和Xcode,再重新打开测试:killall "Simulator" killall Xcode - 重置模拟器状态:打开模拟器,选择菜单栏
模拟器->重置内容和设置,确认后重启模拟器再运行测试。 - 调整并行测试数量:在Xcode的scheme配置中,找到测试阶段的并行设置,将同时运行的测试数限制在5个以内,避免触发模拟器启动冲突。
- 升级/降级Xcode:该问题在Xcode 14.x版本中存在偶发案例,尝试升级到14.4及以上版本,或切换到稳定版14.3。
- 检查系统权限:前往
系统设置->隐私与安全性,确认Xcode和Simulator拥有必要的系统权限。
内容的提问来源于stack exchange,提问作者Tometoyou
相关产品推荐
相关产品推荐

