'xcodebuild test : Could not launch simulator: -10827

I am running my build agent as a launch agent. I get this error when I try to run "xcodebuild test ..." :

2016-07-14 16:31:00.535 xcodebuild[11579:21390] [MT] iPhoneSimulator: Could not launch simulator: -10827 xcodebuild: error: Failed to build project XcodeTestsTest1 with scheme XcodeTestsTest1. Reason: The operation couldn’t be completed. (OSStatus error -10827.)

Do you have any idea about how can this issue be solved?

Thanks!



Solution 1:[1]

I had exact same issue. It happens because Mac OS X doesn't allow an iOS simulator to run in the BACKGROUND.

If you are constructing a Jenkins CI environment, and trying to unit test via the simulator, you can't run the simulator, because Jenkins is basically run as a DAEMON. This also happens if you're running the tests behind environments like tmux or screen.

Here is a great tutorial to read that can help you fix this.

Cheers!

Solution 2:[2]

For me this helped - close XCode & Simulator (if running) - open Terminal and type:

ps -ax | grep simdeviceio | grep -v grep

this had some output on my Mac:

50755   ??  Ss     0:00.67 /Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/Resources/SimStreamProcessorServices.simdeviceio/Contents/XPCServices/SimStreamProcessorService.xpc/Contents/MacOS/SimStreamProcessorService
50756   ??  Ss     0:00.07 /Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/Resources/SimAudioProcessorServices.simdeviceio/Contents/XPCServices/SimAudioProcessorService.xpc/Contents/MacOS/SimAudioProcessorService

This 2 processes could either manually be killed by typing their PIDs (first number in above lines) with a kill command:

kill -9 50755 50756

or with

ps ax | grep simdeviceio | grep -v grep | awk '{print $1}' | xargs kill -9

Solution 3:[3]

If you run

xcrun simctl boot "iPhone 7"

then

run xcodebuild test

then after cleanup with

xcrun simctl shutdown "iPhone 7"

Note: you have to have an active user session running somewhere on the box you are trying to run this on.

Solution 4:[4]

Go to the apple icon (top left of screen), then force quit then select the simulator

Run the project again

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ArielSD
Solution 2 hwde
Solution 3 rfranczyk
Solution 4 Johana Lopez 1327