Failed to launch DeviceAgent - ExitCode: 65

Hi,

I'm trying to set up UITests for iOS in Visual Studio for Mac, but always running into the same error:

SetUp : Xamarin.UITest.XDB.Exceptions.DeviceAgentException : Failed to launch DeviceAgent
ExitCode: 65

I've tried setting up a completely blank iOS solution and followed every single step stated in the tutorial article.

I want to test in the simulator on my Mac.
Starting the app in the simulator works as expected.

I'm using following environment:

  • Mac Pro, macOS 10.13.2
  • Visual Studio Community 7.3.3
  • Xamarin.iOS 11.6.1.3
  • Xamarin.Mac 4.0.0.215
  • Xamarin.UITest 2.2.3 (in UITests project)
  • Nunit 3.9.0 (in UITests project)
  • Xamarin.TestCloud.Agent 0.21.4 (in iOS project)

I've tried various simulators (like iPhone 7,8,X and so on, running on iOS 11.2).
In Tests.cs I'm using the default template. Also, the app is included in the solution.

So when running the test, the simulator first starts up, the DeviceAgent is being installed and opened (black screen).
After that the DeviceAgent closes again, and installes itself again one more time. After that, DeviceAgent is being opened and stays at a black screen.
The test failes in VS17 and returns the error stated below.

I've tried deleting the 'XDB' folder inside /var/folders/ as adviced in a stackoverflow question.

Thanks for any kind of advice, I'm running out of ideas.

namespace testinguitests.UITests
    {
        [TestFixture]
        public class Tests
        {
            iOSApp app;

            [SetUp]
            public void BeforeEachTest()
            {
                // TODO: If the iOS app being tested is included in the solution then open
                // the Unit Tests window, right click Test Apps, select Add App Project
                // and select the app projects that should be tested.
                //
                // The iOS project should have the Xamarin.TestCloud.Agent NuGet package
                // installed. To start the Test Cloud Agent the following code should be
                // added to the FinishedLaunching method of the AppDelegate:
                //
                //    #if ENABLE_TEST_CLOUD
                //    Xamarin.Calabash.Start();
                //    #endif
                app = ConfigureApp
                    .iOS
                    // TODO: Update this path to point to your iOS app and uncomment the
                    // code if the app is not included in the solution.
                    //.AppBundle ("../../../iOS/bin/iPhoneSimulator/Debug/testinguitests.UITests.iOS.app")
                    .StartApp();
            }

            [Test]
            public void AppLaunches()
            {
                app.Screenshot("First screen.");
            }
        }
    }

Log:

Xamarin.UITest.XDB.Exceptions.DeviceAgentException : Failed to launch DeviceAgent

ExitCode: 65




    IDEDerivedDataPathOverride = /var/folders/_q/hwspjqfx5t9253vx5v0h6_q00000h2/T/xdb/logs/2018.02.22.104544/DerivedData
    IDETestRunSpecificationPath = /var/folders/_q/hwspjqfx5t9253vx5v0h6_q00000h2/T/xdb/logs/2018.02.22.104544/DeviceAgent-simulator.xctestrun
    t =     0.00s Start Test at 2018-02-22 10:45:52.806
    t =     0.05s Set Up
     Executed 1 test, with 1 failure (0 unexpected) in 0.000 (0.000) seconds
     Executed 1 test, with 1 failure (0 unexpected) in 0.000 (0.002) seconds
        SimDevice: iPhone 8 (9F9DF7AF-1095-44D2-9700-C40686870319, iOS 11.2, Booted)
        SimDevice: iPhone 8 (9F9DF7AF-1095-44D2-9700-C40686870319, iOS 11.2, Booted)
** TEST EXECUTE FAILED **
/var/folders/_q/hwspjqfx5t9253vx5v0h6_q00000h2/T/com.apple.dt.XCTest/IDETestRunSession-40AA227C-4A68-48C4-A74E-25093797C52F/DeviceAgent-FEADC885-A026-41AE-BF47-1D3CE5DE4A32/Session-DeviceAgent-2018-02-22_104545-QrveLk.log
/var/folders/_q/hwspjqfx5t9253vx5v0h6_q00000h2/T/com.apple.dt.XCTest/IDETestRunSession-40AA227C-4A68-48C4-A74E-25093797C52F/DeviceAgent-FEADC885-A026-41AE-BF47-1D3CE5DE4A32/Session-DeviceAgent-2018-02-22_104555-RnirS3.log
} (11.2 (15C107))
} (11.2 (15C107))
2018-02-22 10:45:45.752 xcodebuild[71952:396632948]  IDETestOperationsObserverDebug: Writing diagnostic log for test session to:
2018-02-22 10:45:45.753 xcodebuild[71952:396632892] [MT] IDETestOperationsObserverDebug: (FA7488EE-3C05-4150-928B-DF857EE78E60) Beginning test session DeviceAgent-FA7488EE-3C05-4150-928B-DF857EE78E60 at 2018-02-22 10:45:45.753 with Xcode 9C40b on target <DVTiPhoneSimulator: 0x7fbfc3879b20> {
2018-02-22 10:45:50.094 DeviceAgent-Runner[71976:396633348] +[CATransaction synchronize] called within transaction
2018-02-22 10:45:50.183 DeviceAgent-Runner[71976:396633348] Running tests...
2018-02-22 10:45:52.162 DeviceAgent-Runner[71976:396633348] Continuing to run tests in the background with task ID 1
2018-02-22 10:45:52.857 DeviceAgent-Runner[71976:396633348] TEST RUNNER IS STARTING
2018-02-22 10:45:55.245 xcodebuild[71952:396632892] [MT] IDETestOperationsObserverDebug: (6C8BA8B4-1929-4BE0-9C3C-46CA3CDD4EF1) Beginning test session DeviceAgent-6C8BA8B4-1929-4BE0-9C3C-46CA3CDD4EF1 at 2018-02-22 10:45:55.246 with Xcode 9C40b on target <DVTiPhoneSimulator: 0x7fbfc3879b20> {
2018-02-22 10:45:55.245 xcodebuild[71952:396633175]  IDETestOperationsObserverDebug: Writing diagnostic log for test session to:
2018-02-22 10:45:58.024 DeviceAgent-Runner[71994:396634283] +[CATransaction synchronize] called within transaction
2018-02-22 10:45:58.059 DeviceAgent-Runner[71994:396634283] Running tests...
2018-02-22 10:45:58.299 DeviceAgent-Runner[71994:396634283] Continuing to run tests in the background with task ID 1
Restarting after unexpected exit or crash in TestRunner/testRunner; summary will include totals from previous launches.
Test Case '-[TestRunner testRunner]' started.
Test Suite 'All tests' started at 2018-02-22 10:45:52.802
Test Suite 'DeviceAgent.xctest' failed at 2018-02-22 10:45:58.913.
Test Suite 'DeviceAgent.xctest' started at 2018-02-22 10:45:52.803
Test Suite 'DeviceAgent.xctest' started at 2018-02-22 10:45:58.913
Test Suite 'Selected tests' failed at 2018-02-22 10:45:58.914.
Test Suite 'Selected tests' started at 2018-02-22 10:45:58.912
Test Suite 'TestRunner' started at 2018-02-22 10:45:52.805
User defaults from command line:

Posts

  • deborahdcarlodeborahdcarlo Member ✭✭

    I am with the same problem. Any solution?

  • denizsaglamdenizsaglam Member ✭✭

    I have been getting this problem as well, almost daily. In the past, somehow it went away and I could run my tests again after struggling for 1-2 hours every day, but now no matter what I try it fails.

    Currently I have:

    • Xamarin.UITest 2.2.4,
    • NUnit 2.6.4,
    • NUnitTestAdapter 2.1.1,
    • Xamarin.TestCloud.Agent 0.21.5.

    Side note: I can successfully send my tests to cloud and run there. It's just app.Repl() not working for me.

  • denizsaglamdenizsaglam Member ✭✭

    Here is the error log I get when I try to run app.Repl() :

    SetUp : Xamarin.UITest.XDB.Exceptions.DeviceAgentException : Failed to launch DeviceAgent
    
    ExitCode: 65
    
    
        IDEDerivedDataPathOverride = /var/folders/59/vb7871h97399_dktl35cq6580000gp/T/xdb/logs/2018.04.18.114633/DerivedData
        IDETestRunSpecificationPath = /var/folders/59/vb7871h97399_dktl35cq6580000gp/T/xdb/logs/2018.04.18.114633/DeviceAgent-simulator.xctestrun
            SimDevice: iPhone X (DBD5BC2A-AB7D-4F01-9C7F-DEF6C0E8988F, iOS 11.2, Booted)
    ** TEST EXECUTE FAILED **
    /var/folders/59/vb7871h97399_dktl35cq6580000gp/T/com.apple.dt.XCTest/IDETestRunSession-B7C04425-F5AA-4033-8208-B800DCDF298B/DeviceAgent-920098CB-2449-4901-B09E-6DF5FE7D7CB7/Session-DeviceAgent-2018-04-18_114636-uAwcP6.log
    } (11.2 (15C107))
    2018-04-18 11:46:36.600 xcodebuild[35725:1233275]  IDETestOperationsObserverDebug: Writing diagnostic log for test session to:
    2018-04-18 11:46:36.602 xcodebuild[35725:1233265] [MT] IDETestOperationsObserverDebug: (59F60D65-71DE-4CBA-9D51-6B40FAD3C927) Beginning test session DeviceAgent-59F60D65-71DE-4CBA-9D51-6B40FAD3C927 at 2018-04-18 11:46:36.600 with Xcode 9C40b on target <DVTiPhoneSimulator: 0x7fbe57e07520> {
    2018-04-18 11:46:41.060 xcodebuild[35725:1233265] Error Domain=IDETestOperationsObserverErrorDomain Code=6 "Early unexpected exit, operation never finished bootstrapping - no restart will be attempted" UserInfo={NSLocalizedDescription=Early unexpected exit, operation never finished bootstrapping - no restart will be attempted}
    2018-04-18 11:46:41.060 xcodebuild[35725:1233265] Error Domain=IXUserPresentableErrorDomain Code=1 "This app could not be installed at this time." UserInfo={NSLocalizedDescription=This app could not be installed at this time., NSUnderlyingError=0x7fbe5a4e96c0 {Error Domain=MIInstallerErrorDomain Code=35 "Failed to load Info.plist from bundle at path /Users/deniz/Library/Developer/CoreSimulator/Devices/DBD5BC2A-AB7D-4F01-9C7F-DEF6C0E8988F/data/Library/Caches/com.apple.mobile.installd.staging/temp.bJGXzP/extracted/Payload/DeviceAgent-Runner.app/Frameworks/XCTAutomationSupport.framework" UserInfo={LegacyErrorString=PackageInspectionFailed, FunctionName=-[MIBundle _validateWithError:], SourceFileLine=38, NSLocalizedDescription=Failed to load Info.plist from bundle at path /Users/deniz/Library/Developer/CoreSimulator/Devices/DBD5BC2A-AB7D-4F01-9C7F-DEF6C0E8988F/data/Library/Caches/com.apple.mobile.installd.staging/temp.bJGXzP/extracted/Payload/DeviceAgent-Runner.app/Frameworks/XCTAutomationSupport.framework}}}
    2018-04-18 11:46:41.062 xcodebuild[35725:1233300] Connection peer refused channel request for "dtxproxy:XCTestManager_IDEInterface:XCTestManager_DaemonConnectionInterface"; channel canceled <DTXChannel: 0x7fbe5aa132d0>
    User defaults from command line:
    
  • olzznolzzn Member

    I found a solution for my problem.
    In my case I had Safari Web Inspector running on my system which, in fact, blocked the port which is used by Xamarin.UITest (Port 27753 on localhost) both for simulators and physical devices.

    Try using following command in Terminal to check for services using that port, and if so, kill them.
    netstat -vanp tcp | grep 27753

  • denizsaglamdenizsaglam Member ✭✭

    @olzzn said:
    I found a solution for my problem.
    In my case I had Safari Web Inspector running on my system which, in fact, blocked the port which is used by Xamarin.UITest (Port 27753 on localhost) both for simulators and physical devices.

    Try using following command in Terminal to check for services using that port, and if so, kill them.
    netstat -vanp tcp | grep 27753

    Hi olzzn, thank you for your post. I have tried your suggestion, unfortunately the problem still persists on my side. Any further suggestions are appreciated.

Sign In or Register to comment.