Xcode 12 issues running multiple test suites with 'Underlying Error: Invalid device state' [only when running via SSH]

We're running into an odd issue only when running our test suite on CI (Jenkins) with Xcode 12: xctest reports

Code Block
xctest encountered an error (Failed to install or launch the test runner. If you believe this error represents a bug, please attach the result bundle at /Volumes/ebs_jenkins/workspace/xcode12-sandbox/derivedData/Logs/Test/Test-Xcode12Sandbox-2020.10.08_02-50-12-+0000.xcresult. (Underlying Error: Invalid device state))


Interestingly, this issue ONLY presents itself when initiated via SSH, when using Screen Sharing (VNC) and running the test suite via Xcode UI, tests pass as expected.

The tests also pass fine on the same CI machine with Xcode 11.5.

You can find a sample project that exhibits the problem here: https://github.com/opfeffer/xcode12-sandbox
I am facing the same issue.
Same here.

Mine gets fixed when running sudo xcrun simctl shutdown all from within the vm, running this sudo-less doesn't work.

Did you find any solution/workaround?
Has anyone found a workaround for this yet?
I'm still fighting the same issue...

I tried Xcode to 12.1 GM, Xcode 12.2 beta 2 and latest stable with no luck.
Anyone able to find any solution or workaround for the same?
I'm facing the same issue as well.
Still a problem we're having. What's the fix?

For us it's:


[2020-11-16T16:12:10.276Z] REDACTED.app encountered an error (Failed to install or launch the test runner. If you believe this error represents a bug, please attach the result bundle at /REDACTED.xcresult. (Underlying Error: The request to open "com.REDACTED.REDACTEDapp" failed. The request was denied by service delegate (SBMainWorkspace) for reason: Busy ("Application cannot be launched because it has outstanding termination assertions"). (Underlying Error: The operation couldn’t be completed. Application cannot be launched because it has outstanding termination assertions.)))

I'm hitting the same issue with XCode 12.2 on Catalina 10.15.7. Just updated our CI server and now everything is busted.
We are facing the issue - completely broke our gitlab-fastlane CI/CD setup. Are there any updates? For us the sudo xcrun simctl shutdown all unfortunately does not work.
Disheartening that these tools present us with another insurmountable error. For me it's only with an M1 MacBook Pro and trying to run unit tests on a Framework. For me, I get: Underlying Error: Invalid device state.
I get the same error on a M1 MacBook Pro when running unit tests on a framework. On both Xcode 12.4 and 12.5 beta
Same here. I have a new mac mini added to the CI and I get the "Underlying Error: Invalid device state" error only on this new machine. chip: Apple M1, OS: Big Sur 11.2.1, Xcode: 12.2 and 12.4 (same error), sim runtime iOS 14.0

Same code on OS Catalina 10.15.7, xcode 12.2, runtime iOS 14.0 is running perfectly.

When do you guys get this error? What command do you run?
In my case is for "xcodebuild clean test" using destination 'platform=iOS Simulator', runtime iOS 14.0

I'll test with different runtime version and come back with the results.
I started to see this issue right after upgrading to Apple M1.

xctest encountered an error (Failed to install or launch the test runner. If you believe this error represents a bug, please attach the result bundle at /Users/nalex/Library/Developer/Xcode/DerivedData/App-aneasilnxtjatpdadaucmmgyspqa/Logs/Test/Run-LibName-Unit-Tests-2021.02.20_17-38-24-+0300.xcresult. (Underlying Error: Invalid device state))

In my case, this is the output of the pod lib lint running unit tests from the command line on my machine. The same tests run OK from Xcode.




For me it was happening on my local machine. I've been able to fix it by going to Project settings, selecting my test target, then in General tab changing "Host application" from "None" to name of my main app target. (the issue was happening for unit tests of my custom framework linked to my app)

Interestingly enough it was working before on my M1 MacBook, but after sometime suddenly this error started to appear. For no apparent reason.
I realized this was happening only for unit tests for my custom framework linked to my app. Not for my main apps unit tests.
I tried even to reinstall the Xcode and after that it worked for little time. But then I dug into totally unrelated issues with Playgrounds which don't work either on my machine and after that the error began to appear again.
Changing the Host application for unit tests seems to be fixing it for now.
Appears that running Xcode under Rosetta produces this error, works when rosetta is disabled for Xcode
Xcode 12 issues running multiple test suites with 'Underlying Error: Invalid device state' [only when running via SSH]
 
 
Q