Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simulator is not started #1943

Closed
fastlane-bot-helper opened this issue Oct 30, 2015 · 24 comments
Closed

Simulator is not started #1943

fastlane-bot-helper opened this issue Oct 30, 2015 · 24 comments

Comments

@fastlane-bot-helper
Copy link
Contributor

Original issue by @yakimant - Imported from fastlane/scan#26

I've got this issue:
2015-10-30 16:56:05.815 xcodebuild[53793:347720] iPhoneSimulator: Timed out waiting 120 seconds for simulator to boot, current state is 1.

I've got it before tunning xcodebuild (xctool didn't have this issue).
It is solved by running the simulatore (instrument -w or ios-sim).

But maybe it can be solved inside scan?

Appreciate you work!

@fastlane-bot-helper
Copy link
Contributor Author

@xfreebird commented

@yakimant mostly likely you have a slow machine. are your running on a CI box or manually from command line ?

@KrauseFx in xctest that was tackled by retrying the execution of tests if such a message would appear.

@fastlane-bot-helper
Copy link
Contributor Author

@yakimant commented

It was on my laptop. I cant increase timeout to be sure.
But even can't see the simulator window opening.

Also - We had such case on CI with plain xcodebuild and fixed it with simulator running
We also have some projects not failing with this issue. It must be some xcodebuild error.

@fastlane-bot-helper
Copy link
Contributor Author

@xfreebird commented

@yakimant have you checked the xcodebuild log ? ~/Library/Logs/scan

@fastlane-bot-helper
Copy link
Contributor Author

@yakimant commented

Hmm, it suddenly disappeared. Will play around and post here the updates.

@fastlane-bot-helper
Copy link
Contributor Author

@yakimant commented

Ok, I'm getting this issue even with -destination-timeout 500.
From log I can't see anything suspicious.

@fastlane-bot-helper
Copy link
Contributor Author

@xfreebird commented

-destination-timeout is for real devices, it doesn't help when using simulators

@fastlane-bot-helper
Copy link
Contributor Author

@yakimant commented

Anyway, it didn't help, so I'm starting the simulator manually as before:
Process.fork { system "xcrun instruments -t 'Blank' -l 1 -w '#{options[:device] } (#{options[:os]})'" }
And killing afterwards:
killall "Simulator"

@fastlane-bot-helper
Copy link
Contributor Author

@yakimant commented

Should this be closed?
I can think of two ways of fix:

  1. add scan parameter to run/stop simulator explicitly
  2. add run/stop simulator actions

@fastlane-bot-helper
Copy link
Contributor Author

@alexanderjrobinson commented

I am seeing the same issue. Runs fine on my local machine but not on my CI server which is a reasonably powerful Mac Mini. It works sometimes but more often than not the build fails waiting on the simulator.

In my case the simulator is launched (possibly from a previous build), so it is at least launching the simulator.

@fastlane-bot-helper
Copy link
Contributor Author

@nitinalabur commented

Runs fine on my CI server, when I run it myself, but fails when jenkins on the same machine tries to run scan as part of a lane. (getting the 120 second timeout error)

@fastlane-bot-helper
Copy link
Contributor Author

@scottrhoyt commented

+1. Good on local. Fails on CI running on a VM (Bitrise).

@fastlane-bot-helper
Copy link
Contributor Author

@alexanderjrobinson commented

Any update or workaround for this issue?

@fastlane-bot-helper
Copy link
Contributor Author

@scottrhoyt commented

My workaround is to test using xctool as opposed to scan.

@fastlane-bot-helper
Copy link
Contributor Author

@scottrhoyt commented

Anyone able to verify if this is fixed in 7.2.1:

Command line tool 'xcodebuild test' will no longer time out waiting for Simulator.app to launch

@fastlane-bot-helper
Copy link
Contributor Author

@alexanderjrobinson commented

I am still seeing the same issue on the CI server after upgrading to 7.2.1.

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

@MarkMolina
Copy link

MarkMolina commented May 4, 2016

Same here after updating scan to 0.6.0 :(

@TKBurner
Copy link

TKBurner commented May 9, 2016

Hi @MarkMolina Thanks for reaching out. Can you share the full output from running scan --verbose? I want to take a look. Thanks! 👍

@KrauseFx
Copy link
Member

Closing this now due to inactivity. Feel free to submit a new issue if you find the time 👍

@nitinalabur
Copy link

nitinalabur commented May 16, 2016

Something I have noticed as to why this happens: if the CI simulator is not matching that of your fastfile/scanfile (e.g., CI has it set as iPhone 4S and your Fastlane sets it as 5s) this issue persists.

When you run scan/Fastlane on your local machine, whichever hardware pops up in your iOS simulator, set that as the device to test against in your scan/fast file

@nitinalabur
Copy link

I have a solution that works for me. I was trying to run scan from Jenkins on a mac mini server, and would often have the issue ("Timed out waiting for 120 seconds...").

Problem was with the current selected iOS simulator (if you were to launch the app on mac through spotlight or finder) not matching the device I was setting for Scan.

Here's the fastlane lane I run on jenkins

desc "Runs all the tests"
  lane :test do
    scan( scheme: "MyTestTarget",
          device: "iPhone 4s",  # <-- should match the current 'selected device' in jenkins' simulator 
                                #     (Simulator-> Hardware -> Device -> iOS -> iPhone 4s)
          clean: true)
  end

If the iOS simulator is set to iPhone 4s and the device selected in the Scan:Device parameter is iPhone 4s, no issues.

So, before running any fastlane commands on Jenkins, I run this shell script

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 4s (${latest_ios})\n"
simulator_id=$(xcrun instruments -s | grep -Eo "iPhone 4s \(${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 4s (${latest_ios})\n"
   exit 1;
fi 
printf "Simulator launched for iPhone 4s (${latest_ios})\nStarting build...\n"

fastlane ios test

the above code is just a slight variation (iPhone type) based on jasontaft's super helpful code/comment here . if you wish to use a simulator for any other device, all you need to do is make the tweak I made.

With this, when I hit "Build Now", it runs my 'ios test' lane as expected, without any hiccups. Hope this helps!

@TKBurner
Copy link

@nitinalabur Thanks so much for sharing. I'm glad to hear you are up and running. Hope that you have a wonderful week!

@kutschenator
Copy link

kutschenator commented Jun 29, 2016

@nitinalabur Just a quick addition: if your simulator is not running yet, the script will fail because killall returns 1. If you change it to this it will work:
killall "Simulator" || true

@nitinalabur
Copy link

@eyeballz I haven't had that issue when the simulator is not running. Should that issue occur, I'll certainly try your suggestion and post an update here. Thanks for sharing that!

@sebromero
Copy link

I use a slightly modified version that accepts the device name as parameter:

#!/bin/bash

if [ "$1" = "" ]; then
    echo "Usage: launch-ios-simulator.sh <device name>"
    exit 1;
fi

device="$1"
printf "Closing any open instances of the iphone simulator...\n"
killall "Simulator" || true
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 ${device} (${latest_ios})\n"
simulator_id=$(xcrun instruments -s | grep -Eo "${device} \(${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 ${device} (${latest_ios})\n"
   exit 1;
fi 
printf "Simulator launched for ${device} (${latest_ios})\n"

Sample usage:

 before_all do
    ENV["FASTLANE_XCODE_LIST_TIMEOUT"] = "120"
    sh "./launch-ios-simulator.sh 'iPad Air 2'"
 end

This works well for me. No more stalling builds.

@fastlane fastlane locked and limited conversation to collaborators Dec 6, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants