Attempting to run Xcode unit tests via ssh to another machine causes simulator to time out

Originator:lwdupont
Number:rdar://18282084 Date Originated:09/09/2014
Status:Duplicate Resolved:
Product:Xcode Product Version:6 beta 7
Classification:Serious Reproducible:Yes
 
Summary:
When we attempt to run unit tests via ssh on another Mac the unit tests fail because the simulator fails to launch.

Steps to Reproduce:
1. Install Xcode 6 beta 7 onto a remote machine
2. Copy the attached project to the remote machine
3. SSH into that remote machine from another Mac
4. Run the unit tests via command line

xcodebuild -project UnitTestJenkinsTest.xcodeproj -sdk iphonesimulator8.0 -scheme UnitTestJenkinsTest -verbose clean test

Expected Results:
The unit tests run on the remote machine, like they did under Xcode 5.

Actual Results:
The unit tests time out with a simulator failed to launch error:

Touch /Users/ctobuilduser/workspace/iOSUnitTestTest/build/Release-iphonesimulator/UnitTestJenkinsTestTests.xctest
    cd /Users/ctobuilduser/workspace/iOSUnitTestTest/UnitTestJenkinsTest
    export PATH="/Applications/Xcode6-Beta7.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode6-Beta7.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
    /usr/bin/touch -c /Users/ctobuilduser/workspace/iOSUnitTestTest/build/Release-iphonesimulator/UnitTestJenkinsTestTests.xctest

2014-09-04 15:25:19.237 xcodebuild[2670:450b]  iPhoneSimulator: Timed out waiting 120 seconds for simulator to boot, current state is 1.

Testing failed:
	Test target UnitTestJenkinsTestTests encountered an error (Timed out waiting 120 seconds for simulator to boot, current state is 1. If you believe this error represents a bug, please attach the log file at /var/folders/2r/tklh34_52j95v7tx0lqr2myc0000gq/T/com.apple.dt.XCTest-status/Session-2014-09-04_15:23:19-aAQozT.log)
** TEST FAILED **

Version:
Xcode 6 beta 7, OS X 10.9.4

Notes:


Configuration:


Attachments:
'UnitTestJenkinsTest.zip' was successfully uploaded.

Comments

If that's the case, why does it happen also on Xcode Server 4.1.3 and Xcode 6.3?

2015-07-06 22:06:45.335 Initializing test infrastructure. 2015-07-06 22:08:45.335 Test operation failure: Timed out waiting 120 seconds for simulator to boot, current state is 1. 2015-07-06 22:08:45.335 _finishWithError:Error Domain=IDEUnitTestsOperationsObserverErrorDomain Code=3 "Timed out waiting 120 seconds for simulator to boot, current state is 1." UserInfo=0x7fe168bb6af0 {NSLocalizedDescription=Timed out waiting 120 seconds for simulator to boot, current state is 1.} didCancel: 1 2015-07-06 22:08:45.335 Finished syncing device diagnostic logs after 0.0s.

By valerio.mazzeo at July 8, 2015, 9:37 p.m. (reply...)

The context provided by LaunchDaemons is not supported for running GUI applications. The SSH service, and the default setup for Jenkins, are both implemented as LaunchDaemons. In earlier versions of Xcode 5 xcodebuild could run tests on the iOS simulator in this context, but that was never a supported configuration, and as you have noted that is no longer working as of Xcode 6.

Unlike LaunchDaemons, LaunchAgents provide a context where you can run GUI applications - if the user is logged in at the time, with a window server / Aqua session. Converting your Jenkins configuration from being a LaunchDaemon to being a LaunchAgent would avoid the reported issue. You can also use launchd for running tests on the iOS simulator from a SSH session, either by crafting a LaunchAgent and manually loading / starting that, or by using "launchctl submit”.

Marked Duplicate of 18055003


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!