iPhoneSimulator Timed out waiting 120 seconds for simulator to boot, current state is 1

I’m getting the iPhoneSimulator timeout errors. Here’s the actual error:

Touching AppTests.xctest 2015-10-28 12:39:03.947 xcodebuild[2157:9798] iPhoneSimulator: Timed out waiting 120 seconds for simulator to boot, current state is 1. Testing failed: Test target AppTests 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/jm/fw86rxds0xn69sk40d18y69m0000gp/T/com.apple.dt.XCTest-status/Session-2015-10-28_12:37:03-xACeDA.log) ** TEST FAILED ** set -o pipefail && xcodebuild CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= PROVISIONING_PROFILE= -sdk iphonesimulator -destination ‘platform=iOS Simulator,OS=8.1,name=iPhone 6’ -workspace AppTest.xcworkspace -scheme “App” -derivedDataPath ./build analyze clean build test | tee $CIRCLE_ARTIFACTS/xcode_raw.log | xcpretty --color --report junit --output $CIRCLE_TEST_REPORTS/xcode/results.xml returned exit code 65

Here’s my xcodebuild line:

test:
    override:
        - set -o pipefail &&
            xcodebuild
            CODE_SIGNING_REQUIRED=NO
            CODE_SIGN_IDENTITY=
            PROVISIONING_PROFILE=
            -sdk iphonesimulator
            -destination 'platform=iOS Simulator,OS=8.1,name=iPhone 6'
            -workspace App.xcworkspace
            -scheme "App"
            -derivedDataPath ./build
            analyze clean build test |
        tee $CIRCLE_ARTIFACTS/xcode_raw.log |
        xcpretty --color --report junit --output $CIRCLE_TEST_REPORTS/xcode/results.xml        -scheme "My Scheme"
        clean build test |
      tee $CIRCLE_ARTIFACTS/xcode_raw.log |
      xcpretty --color --report junit --output $CIRCLE_TEST_REPORTS/xcode/results.xml

I also tried to use xctool instead to see if xctool gives gives me better results, but xctool gives me this error:

ERROR: Unexpected action: -derivedDataPath

I need to use -derivedDataPath and although this command option is valid when I tested locally, it appears that the xctool preinstalled in the CircleCI container doesn’t support that option. I tried to brew uninstall xctool and install the latest but that hangs the build when xctool is called.

I’m not sure why iPhoneSimulator suddenly started timing out but I’d love to hear if anyone has a suggestion.

1 Like

Same exact issue here. No solution yet. Tried adding timeout extension as suggested by circle. No success with that since it’s a simulator timeout and not a circle timeout. Tagging along hoping to find a solution.

My work around was to disable code coverage. I noticed that this timeout issue only started when code coverage was enabled.

After much research on this topic the problem seems to be with xcodebuild and a time out that Apple has in place. There seems to be lots of people seeing this issue. I’m not entirely sure what your setup is but as for mine I was running a tests scheme. This scheme was a combination of five applications in our suite that have shared components. Running this scheme all at once to generate coverage was working for quite some time. At some point we passed the threshold that put us over the time out. This timeout seems to start before compile time and expect the app to open in 120 seconds. The way that I’ve managed to work around this was to split out my tests. Rather than run all app tests in a single scheme I now run tests for each individual app and our components separately. This results in the derived data containing coverage reports for each app which we combine into a single file to send to our coverage report system.

Again I’m not sure that this solution fits your situation if it’s a single app that needs to compile fully to run tests you may not be able to run it this way. But it’s something to think about. Splitting out test schemes in some way might help. I’d be happy to answer more questions if you decide to go down this path and need help.

Hope this was useful information.

We launch the simulator before running xcodebuild (with code coverage). We are recently seeing the following command fail to launch the simulator, but when it does (grrr… circleci inconsistencies) you will avoid the timeout issue.

Something like (change for whatever simulator you need):

printf "Closing any open instances of the iphone simulator...\n"
killall "Simulator"
printf "Determining latest iOS simulator...\n"
latest_ios=$(xcodebuild -showsdks | grep -Eo "iphonesimulator(.+)" | tail -1)
latest_ios=${latest_ios##iphonesimulator}
printf "Detected latest iOS simulator version: ${latest_ios}\n"
printf "Pre-Launching iphone simulator for iPhone 6 (${latest_ios})\n"
simulator_id=$(xcrun instruments -s | grep -Eo "iPhone 6 \(${latest_ios}\) \[.*\]" | grep -Eo "\[.*\]" | sed "s/^\[\(.*\)\]$/\1/")
open -b com.apple.iphonesimulator --args -CurrentDeviceUDID $simulator_id

RETVALUE=$?
if [ "$RETVALUE" != "0" ]; then
   printf "Something went wrong when attempting to launch the simulator for iPhone 6 (${latest_ios})\n"
   exit 1;
fi 
printf "Simulator launched for iPhone 6 (${latest_ios})\nStarting build...\n"
1 Like

I had xcodebuild timing out when trying to launch the simulator until I tried adapting the solution that the Swinject people used for Travis CI:

test:
  pre:
    - open -b com.apple.iphonesimulator

As far as I know, there is no need to specify the device in this command, since the xcodebuild command that Circle CI runs by default will cause the simulator to change to whatever device it wants for running the tests.