Unit test not working on Xcode 14 RC

Hello, When I lunch any Unit Test with Xcode 14 RC and iPhone 13 iOS 16 I get this error, any ideas??

Details

Process spawn via launchd failed.

Domain: NSPOSIXErrorDomain

Code: 22

Failure Reason: Invalid argument

User Info: {

    DVTErrorCreationDateKey = "2022-09-08 15:57:43 +0000";

    IDERunOperationFailingWorker = IDELaunchiPhoneSimulatorLauncher;

    Session = "com.apple.CoreSimulator.SimDevice.ECF8B277-7010-4ABD-8EC7-109E80FD2A42";

}

--

The operation couldn’t be completed. (Mach error 22 - (os/kern) invalid host)

Domain: NSMachErrorDomain

Code: 22

--

Analytics Event: com.apple.dt.IDERunOperationWorkerFinished : {

    "device_model" = "iPhone14,5";

    "device_osBuild" = "16.0 (20A360)";

    "device_platform" = "com.apple.platform.iphonesimulator";

    "launchSession_schemeCommand" = Test;

    "launchSession_state" = 1;

    "launchSession_targetArch" = arm64;

    "operation_duration_ms" = 7;

    "operation_errorCode" = 22;

    "operation_errorDomain" = NSPOSIXErrorDomain;

    "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" = 1;

    "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_runnable_type" = 1;

    "param_testing_launchedForTesting" = 1;

    "param_testing_suppressSimulatorApp" = 0;

    "param_testing_usingCLI" = 0;

    "sdk_canonicalName" = "iphonesimulator16.0";

    "sdk_osVersion" = "16.0";

    "sdk_variant" = iphonesimulator;

}

--

System Information

macOS Version 12.5.1 (Build 21G83)

Xcode 14.0 (21335) (Build 14A309)

Timestamp: 2022-09-08T11:57:43-04:00

Answered by sion.jw in 726698022

Edited: I found that just rebooting macOS solves this issue. Setting host application was not needed.

In my case setting Host Application in the test target settings > General > Testing from "None" to the main app solved this issue.

Same here, I still didn't find a fix...

Accepted Answer

Edited: I found that just rebooting macOS solves this issue. Setting host application was not needed.

In my case setting Host Application in the test target settings > General > Testing from "None" to the main app solved this issue.

@sion.jw rebooting my macOS did the trick too, thank you!

I met a similar issue, and I solved like below: About this Mac > Storage > Manage > Developer and Open the screen, delete all cache, then it should work well

I just changed the device simulator in xcode and it worked for me.

In my case, this happened when I had an environment variable set manually for the project via the scheme.

What caused it was an accidentally added environment variable without a name or value.

(Check for it under Product > Scheme > (pick a scheme), select Run from left nav, and inspect the manually configured environment variables.

This won't be the cause for everyone, but the empty name/value pair for the env var definitely is a cause for this error (easily reproducible)

Unit test not working on Xcode 14 RC
 
 
Q