XCUITest: xcodebuild test failed with error: ".. com.apple.testmanagerd.control was invalidated"

Hey there, the following error message appears when running xcodebuild test command on a simulator (through ssh):

IDETestOperationsObserverDebug: Failure collecting logarchive: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.testmanagerd.control was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.testmanagerd.control was invalidated: failed at lookup with error 3 - No such process.}
    2023-03-29 02:09:10.346 xcodebuild[86494:1840011]  IDETestOperationsObserverDebug: Failure collecting logarchive: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.testmanagerd.control was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.testmanagerd.control was invalidated: failed at lookup with error 3 - No such process.}
    2023-03-29 02:09:15.996 xcodebuild[86494:1839901] [MT] IDETestOperationsObserverDebug: 38.573 elapsed -- Testing started completed.
    2023-03-29 02:09:15.996 xcodebuild[86494:1839901] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start
    2023-03-29 02:09:15.996 xcodebuild[86494:1839901] [MT] IDETestOperationsObserverDebug: 38.573 sec, +38.573 sec -- end
    2023-03-29 02:09:16.047 xcodebuild[86494:1839901] [MT] DVTAssertions: Warning in /System/Volumes/Data/SWE/Apps/DT/BuildRoots/BuildRoot2/ActiveBuildRoot/Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-21534/IDEFoundation/Execution/Schemes/IDETestSchemeAction.m:650
    Details:  Error saving invocation record to resultBundlePath:Error Domain=IDEFoundationErrorDomain Code=12 "The scheme actions invocation record could not be saved due to an error." UserInfo={NSLocalizedDescription=The scheme actions invocation record could not be saved due to an error., NSUnderlyingError=0x600003889ce0 {Error Domain=(extension in IDEFoundation):__C.IDESchemeActionTestAttachment.Error Code=0 "failed to import attachment at path /Users/builder/Library/Developer/Xcode/DerivedData/DetoxTester-cgbhqpssigilfwaindwiqzhgiukb/Logs/Test/Test-DetoxTester-2023.03.29_02-08-36--0700.xcresult/Staging/1_Test/Attachments/Screenshot_1_4780DF43-975B-48B2-8DB2-34826BA5B056.jpeg, underlying error: noEntry"}}
 
    Object:   <IDETestSchemeAction: 0x7fc2991353c0>
    Method:   -testOperationWithSchemeOperationParameters:testManager:buildOperation:buildParameters:schemeCommand:actionRecord:testPlanRunSpecification:testRunSpecificationGroups:coverageBuildableInfos:deviceAvailableChecker:outError:actionCallbackBlock:
    Thread:   <_NSMainThread: 0x6000008840c0>{number = 1, name = main}
    Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.
    Failing tests:
...

We solved this with a workaround https://github.com/maplibre/maplibre-gl-native/pull/985

But very interested to know why xcodebuild cannot be run headlessly when it seems like it should be able to in this case.

XCUITest: xcodebuild test failed with error: ".. com.apple.testmanagerd.control was invalidated"
 
 
Q