Wont run under Hudson/Jenkins #5

cgriffin opened this Issue May 10, 2011 · 27 comments


None yet

I always get the following when running under Jenkins:

[DEBUG] Session could not be started: Error Domain=DTiPhoneSimulatorErrorDomain Code=2 UserInfo=0x100270b90 "Simulator session timed out."

If I run the build manually from the workspace dir of jenkins it works. Any ideas?

alloy commented May 10, 2011

Can you elaborate on what you mean by running the build manually? From the terminal?

I have no experience with Jenkins. I'll try to find some time this week to set it up and debug it.

I use ios-simulator with jenkins and it works fine.
cgriffin: can you give us some more informations? Like the whole command you kicking off?



alloy commented May 11, 2011

@jonasschnelli That’s great to hear, thanks! I’ll wait with installing Jenkins to see if further information will allow you to diagnose the problem first.

In our project ios-sim is integrated ad git-submodule and get also a xcodebuild in the build script.
So we ensure that the ios-sim was propperly built on the build-machine itself (no precompiled binary).
This is because the developer dir sometime has different locations.

My xcode target has as it's last step a build script that runs ios-sim. If I do xcodebuild myself it works. When it's called from jenkins it doesn't. I'm not sure how to go about figuring this out. I believe that ios-sim makes the system call to launch the iPhone app and then doesn't hear anything until it times out. There doesn't seem to be any other diagnostic information than that. I would be happy to investigate myself if I knew how to get more information about trying to launch the iPhone app.

jonasschnelli: I'll try compiling ios-sim on our build machine and see if that helps. Here is the line from my script file that runs ios-sim:

/usr/local/bin/ios-sim launch "$RUN_CMD" --env "$ENV_PATH"

The xcode target that builds the app has a run script build phase that runs the script.

yes. it's not trivial.
I've extended my unit test app that it terminate at the end... maybe otherwhise it would break jenkins build-run.

What's on your build-servers screen during the jenkins build process?
Can you see the simulator?
Is there a app loaded?

What you also can try it to "cd" to the jenkins job-dir and try to launch the ios-sim on the buildserver.
Always set the --std-err parameter to a file which can be used to debug later.

Added --std-err but the file is never created. It does report the path to the stderr file so I know that's working correctly. I still get the same error. I was setting a bunch of malloc/NSZombieEnabled stuff but I commented all that out and still no joy.

The build machine has iOS Simulator showing. I just deleted the app and ran my jenkins build and the app is never installed.

sounds complicated.
What about running ios-sim from the shell manually?
Same issue?

alloy commented May 13, 2011

@jonasschnelli I was thinking that it might be handy to have a basic wiki entry with the steps needed to run it with Jenkins. Could I persuade you to write that? :)

@alloy ... yes. possible. as soon as some time is here... :)

alloy commented May 13, 2011

@jonasschnelli Good enough for me! :)

igoris commented Jun 10, 2011

It seems like the problem is that jenkins runs build as root user.
This is what I found:
if you enter
sudo su
and then run script that will call ios-sim, all is ok
but if you enter
sudo su -
then ios-sim will fail with
[DEBUG] Session could not be started: Error Domain=DTiPhoneSimulatorErrorDomain Code=2 UserInfo=0x100270b90 "Simulator session timed out."

moredip commented Aug 29, 2011

If anyone is still having issues with this, you could check out the simlauncher gem I made a while back. Code is on github or just gem install sim_launcher. It uses an older version of this project (back when it was called iphonesim), but I'd be happy to start using ios-sim if there're benefits.

I actually have been battling essentially the same issue, launching the simulator from Jenkins via Instruments. Same errors, same frustrations. The solution that works for me, strangely enough, is to set up passwordless SSH using public key and have the machine ssh into itself to start and use the simulator. When Jenkins was invoking the simulator through instruments it wasn't working, but sshing from another machine (or user on the same machine, etc.) works. One catch is that the jenkins user also has to be logged into the UI for the simulator to work reliably.

Hope this helps someone.

@quellish.. Hi I am trying to do the same as you did but I am getting "Permission denied (publickey,keyboard-interactive).
" error even after entering correct password. What I am missing here?? Can you please explain a bit about "set up passwordless SSH using public key and have the machine ssh into itself "..

quellish commented Feb 7, 2012

At some point I am going to write a detailed article (and code) for setting up Jenkins to run UIAutomation. @shri-idev , your issue is SSH public key authentication, which rarely works as advertised the first time. Public key authentication removes the need for a password, which is what you need for this to work. These two guides should help you solve your problems:

ehuynh commented Oct 1, 2012

Seems like the problem is to do with how jenkins is launched. When installing Jenkins on our build server, it created the launchd plist in /Library/LaunchDaemons. When trying to launch ios-sim, I encountered the same error above, and as others have pointed out, the issue seems to be that jenkins is no run as the logged in user. By moving the launchd plist to /Library/LaunchAgents instead, so that its run as the logged in user, this solved the problem. Got this idea from square/KIF#72

Moving the launchd plist from /Library/LaunchDaemons to /Library/LaunchAgents, as @ehuynh suggested, worked for me, too.


shazron commented Jan 4, 2013

@ehuynh 's answer seems to be the solution. Closing.

shazron closed this Jan 4, 2013

azubala commented Jan 7, 2013

When ios-sim is launched on Jenkins, I'm facing the described problem: "Simulator session timed out.". I've moved the plist but no luck even after restart of the Jenkins. Should I also restart whole machine?

sammio2 commented Jan 7, 2013

I am also having the same issue, moving the plist file did not work for me. This issue definitely should be re-opened!

mbinna commented Jan 16, 2013

It seems that Jenkins needs to have access to the window server's session so that ios-sim can properly communicate with the iOS Simulator. When I launch Jenkins via ~/Library/LaunchAgents everything works as expected. I wrote an article that describes the whole setup: Continuous Integration of iOS Projects using Jenkins, CocoaPods, and Kiwi

Moving the org.jenkins-ci.plist to ~/Library/LaunchAgents did work on my Jenkins server on MacOSX either. I moved it out of the main drive and into my user folder and still no luck "/Users/me/Library/LaunchAgents" and same error.

I'm having this same issue "Simulator session timed out". Moving the plist files didn't work for me either which might be due to the fact that I'm running my build process on a different node than the master jenkins machine. I CAN run the xcodebuild command that jenkins is running manually from terminal and it works perfectly. But when it is ran from jenkins it fails with "Simulator session timed out". Can ANYONE help with this? I've been searching and searching but have found nothing that helps.

LowAmmo commented Apr 10, 2013

Yes. Had the same issue when running with Jenkins. The problem is that ios-sim launches the actual simulator (window and all). So, you need to have an actual desktop session happening for your jenkins user, so the window has somewhere to launch.
All you need to do is either trigger an auto-login of your Jenkins user, or VNC to the box and log in as the jenkins user. That will start a desktop session for the jenkins user, and then the simulator will be able to correctly launch and run.

This moved my CI efforts forward significantly. I'm having this "simulator session timed out" issue too. In my case, the Hudson server is on windows and the Mac is running as a slave. So, there's no plist file to move. I've noticed that the simulator starts, but i still get the error. Any more thoughts? I think i've tried everything listed here.

When i execute my ant script from the command-line (logged in as the build user), it executes correctly and generates the Junit test files. When i run the same script from the Hudson slave (started via ssh using the same credentials), it fails with this error.

Thanks -- Dan'l

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment