Deploying UI Tests to iOS Device

TonyVlahovicTonyVlahovic Tony VlahovicUSMember
edited October 2014 in Xamarin Test Cloud

Hello - I'm looking to implement UI Tests and I'm running into an issue. Essentially the app starts to launch and then crashes immediately, tries a few times and then fails again. It returns:
Setup : System.Exception : Instruments failed to start the app.

The Stack Trace is:
at Xamarin.UITest.iOS.Instruments.StartInstrumentsInternal (System.String targetApplication, iOSRunType runType, System.String deviceId, System.String runLoopPath) [0x00000] in :0
at Xamarin.UITest.iOS.Instruments.StartInstrumentsHostLoop (System.String targetApplication, iOSRunType runType, System.String deviceId, System.String fifoPath) [0x00000] in :0
at Xamarin.UITest.iOS.iOSApp.RunApp (Xamarin.UITest.Shared.iOS.Queries.DeviceInfo deviceInfo, System.String bundleId, Xamarin.UITest.iOS.Instruments instruments, Xamarin.UITest.Shared.Http.HttpClient httpClient, System.Uri deviceUri) [0x00000] in :0
at Xamarin.UITest.iOS.iOSApp..ctor (IiOSAppConfiguration appConfiguration) [0x00000] in :0
at Xamarin.UITest.Configuration.iOSAppConfigurator.StartApp () [0x00000] in :0
at TheraOffice_Documentation.Tests.LoginTests.SetUp () [0x00000] in /iOS/TheraOffice_Documentation/TheraOffice_Documentation.Tests/LoginTests.cs:29
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00054] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/corlib/System.Reflection/MonoMethod.cs:230

In my setup I've configured the following: (I believe my Bundle ID is correct and my IP Address is correct and on the same network) and it appears it is reaching the device because a black screen launches and crashes 4 times)
public void SetUp ()
//_app = ConfigureApp.iOS.AppBundle (PathToIPA).StartApp ();
_app = ConfigureApp.iOS.DeviceIp ("")
.InstalledApp ("com.rehabsoftware.Documentation")
.ApiKey ("XXXXXXXX")
.StartApp ();

Any thoughts? I also have a follow up question about running this in the simulator which is essentially when I attempt to do that, it launches the iOS 5S 8.0 Simulator and my application is iPad only. I launch the test by right clicking the Test Project and clicking Run Item. Any thoughts how i can get it to launch the iPad Simulator?


  • TonyVlahovicTonyVlahovic Tony Vlahovic USMember

    The clipboard paste did not list everything in the stack trace as well. I do see some starting at Xamarin.UITest.iOS.iOSApp..ctor(IiOSAppConfiguration appConfiguration) which tells me it doesn't know my app location but i think i have it configured correctly. Also I'm on the Alpha Version, going to switch to Beta and give a try.

  • TonyVlahovicTonyVlahovic Tony Vlahovic USMember

    see some "filename unknown" starting at Xamarin.UITest.iOS.iOSApp..ctor(IiOSAppConfiguration appConfiguration)

  • TonyVlahovicTonyVlahovic Tony Vlahovic USMember

    Disregard the Simulator question found it in the forum below

  • MalcolmSmithMalcolmSmith Malcolm Smith USMember

    I had the same problem.

    First thing I found: More detailed logs about what goes wrong during a local Xamarin UITest run are available in [tempPath]/uitest on your Mac. [tempPath] is the path that System.IO.Path.GetTempPath() returns.

    In the test run log files, I saw the error "WebKit Threading Violation - initial use of WebKit from a secondary thread". I Googled around, and found a fix:

    • On your connected iOS 8 device, go to Settings
    • Find the "Developer" section on the left. Look for "Enable UI Automation", and turn that on.

    After doing that, I can start a test run on the iPad, use REPL and look at my view hierarchy, etc.

  • TonyVlahovicTonyVlahovic Tony Vlahovic USMember

    This worked for me. Thanks so much.
    •On your connected iOS 8 device, go to Settings
    •Find the "Developer" section on the left. Look for "Enable UI Automation", and turn that on.

  • TomOpgenorthTomOpgenorth Tom Opgenorth CAXamarin Team Xamurai

    Thanks for letting us know about this. I was unaware if it myself.

  • jeffryvujeffryvu Jeffry van de Vuurst NLMember, University

    Ok, this is going to sound stupid, but how do I actually run the UITest on an actual device? For me it always launches the simulator and I cannot find a way to make it launch on my actual device?

    I've tried pointing to both the .app file in the iPhone and iPhoneSimulator folder and I'm using the unit test runner to start my tests.

  • TomOpgenorthTomOpgenorth Tom Opgenorth CAXamarin Team Xamurai

    I haven't tried it, but this might work for you:

  • jeffryvujeffryvu Jeffry van de Vuurst NLMember, University

    Hi Tom,

    That link seems to be applying to ruby Calabash instead of the Xamarin.UITest C# framework. But now I see in the code of the original poster the following:
    _app = ConfigureApp.iOS.DeviceIp ("") .InstalledApp ("com.rehabsoftware.Documentation") .ApiKey ("XXXXXXXX") .StartApp ();

    That seems to be the way. I will try that.

  • kwlkwl Kerry Lothrop USInsider, Developer Group Leader ✭✭

    @JeffryvandeVuurst Did that work for you? says it shouldn't work but it's working for me on Android.

  • jeffryvujeffryvu Jeffry van de Vuurst NLMember, University

    Good news! By using:

    instead of:

    in the
    ConfigureAppcall I am able to run the Xamarin.UITests on my device.

  • ChrisWoodcockChrisWoodcock Chris Woodcock USMember, University

    I was getting the error reported from each test "Instruments failed to start the app"

    So If you're still getting that after enabling UI Automation on the phone, then this fixed it on both iPhone 5 (8.3) and iPhone 6 (8.1)

    Open the Xcode 6
    Select the Automation
    Target your device and an app on your device (I targeted the one which I was trying to test - but that may not be necessary)

    If you're device is not enabled for development (I don't know what that means!) then will pop a dialog asking you to open Xcode and enable development. Follow instructions and ignore the fact that there is no button in Xcode 6 to "enable for development". After "enabling for development" you're UI tests may start working...

    Thanks to jmoody for that one

  • JohnHardmanJohnHardman John Hardman GBUniversity ✭✭✭✭✭

    @ChrisWoodcock @jeffryvu Many thanks for your posts here. You've saved me a lot of pain :-)

  • TomaszLubockiTomaszLubocki Tomasz Lubocki USMember

    Hi All, In my case it was also a matter of updating Mac OSX version and XCode. After that solution with *.InstalledApp works just perfectly !

  • UdayKumar.9022UdayKumar.9022 Uday Kumar USMember

    Restarting the device worked for me like a charm

Sign In or Register to comment.