iOS Simulator crashes on launch when built using Jenkins automation

I have set up my Jenkins job to build the .app target to open with Appium. In the console output, the build command is

$ /usr/bin/xcodebuild -target MyApp -sdk iphonesimulator9.3 -configuration test_config clean build

I try running the same command on my local machine, and am able to open the .app target with Appium. However, when I run Appium against the .app target generated by my Jenkins job, the simulator will load the launch screen and crash immediately. After doing much searching, I have been unable to get to the source of the problem. I’ve set my Appium settings, enabled native instruments, and a bunch of other things found here and on Stack Overflow but to no avail.

The not so useful crash log I see in the Appium console output is:

[iOSLog] [IOS_SYSLOG_ROW] Jun 1 15:19:11 Dans-MacBook-Pro com.apple.CoreSimulator.SimDevice.9AE7C2C2-3CB4-4A44-8288-AC2924D08A74.launchd_sim[69715] (UIKitApplication:com.myapp.MyApp 0x4fd4][69803]): Service exited due to signal: Trace/BPT trap: 5

Any tips on how to begin to debug this? Thank you!

I know there are countless posts with this generic issue, but hopefully I can help someone debug their own issue. Most solutions had to do with making sure the app was compiling against the correct sdk, and configuring Appium correctly to open the .app or .ipa file. I was doing both of these and still couldn’t figure out why my .app file kept crashing when starting up in the Appium simulator.

I had to build a .ipa file to run on my device, and then check my crash log there in order to debug what was happening. In my case, my crash log showed a couple frameworks weren’t being found. I made these frameworks optional in the project settings, which fixed the crash.

Next I made sure to set the Xcode plugin to build against the iphonesimulator sdk and not generate an ipa so that I could use the .app file on Appium. Finally it worked, but the key was to create the ipa file first so that I could take a peek at the crash logs in my Xcode device window. Whew!

Yes, I am trying to do the exact same thing. I create the app file but don’t know the exact command structure to launch the simulator and run the app. Here is what I am doing: “xcodebuild -sdk iphonesimulator10.2 -workspace /Users/r631173/.jenkins/workspace/tesdir000/mobile-workspace/ios/myWorkspace.xcworkspace -scheme myApp”. This build occurs successfully.

Check this blog post to setup your Jenkins.
http://www.cimgf.com/2015/05/26/setting-up-jenkins-ci-on-a-mac-2/

By default, Jenkins is unable to run GUI applications because it runs as a Daemon. A daemon runs in the background as part of the overall system, and isn’t tied to a specific user.

A big part of CI is running simulators and other GUI applications, so we’ll need another option. To fix this, you can change Jenkins to run as a Launch Agent. A launch agent runs in the background on behalf of a user.

i do not understand your problems… why you are not running mac as SLAVE for jenkins? you will not have any of mentioned problems.

I am running into the same problem.

How do I set up the slave so that the slave uses the same provisioning profile and the developer certificate that the master uses?

@mayu you should just install certificates on slave. best solution before test refresh certificate (if you really need certificates). i do not need certificates for test with Simulator but i need when i build for distribution via HockeyApp.

There are two type of testing I’m trying to do:

  1. Running tests on the iOS simulator on slave
  2. Running tests on AWS Device Farm

So, I guess I do not really need to have the same certificate/provisioning file that the master uses as long as it is a “debug” build built on master? Is debug build the only requirement to get the test running on slave simulator?

The app crash on the slave simulator might be due to the build script configs (probably not having the correct architecture for simulator). Not sure.

how you start script on slave?
my way:

  1. slave has xCode, Java, appium via npm installed
  2. slave test job include following steps:
  • download tests from github
  • start tests
  • other after tests stuff

the slave itself is running as web service via slave.jar

My automation job setup is exactly the same as yours.

There are two jobs - appium automation job and the main iOS app job.

Would it be possible to share your Jenkins build script that is part of your main app job for generating .app and .ipa? I think the root cause of my test app crash on simulator is the build script config not working for the slave simulator. Does yours use the xcode plugin to generate .app and .ipa?

i use xcodebuild for both: create Simulator build and build for HockeyApp.

Try this first: “xcrun simctl install booted MyApp.app” at the CLI where the MyApp.app file resides.

Follow the below blog post to correctly setup the Jenkins box

Setting up Jenkins CI on a Mac