appium icon indicating copy to clipboard operation
appium copied to clipboard

Fail to launch test on real iOS device

Open jeangb opened this issue 9 years ago • 36 comments

The problem

Since 3 days I'm struggling to launch a test on real device. I'm trying to use the XCUITest framework. I've been setting the team on all the targets from the WDA Xcode project. When I launch my test, I've got this error from appium server:

[XCUITest] Unable to start WebDriverAgent: Error: Command 'idevicedate -u e75c0085c74a872846772a6b2ee56a86849a4d92' exited with code 255

Environment

  • Appium version (or git revision) that exhibits the issue: 1.6.3
  • Desktop OS/version used to run Appium: 10.11.6
  • Node.js version (unless using Appium.app|exe): v6.9.1
  • Mobile platform/version under test: iOS 9.3.5
  • Real device or emulator/simulator: real (iPhone 6 plus)
  • Appium CLI or Appium.app|exe: appium CLI
  • Xcode : 8.1

Details

Here's my setup to launch the appium driver:

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"[MY_DEVICE_NAME]");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,"iOS");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "9.3.5");
capabilities.setCapability(MobileCapabilityType.UDID, "[MY_UDID]");
capabilities.setCapability("bundleId", "im.vector.app");//app
		
//TODO: XCUITest is used because Appium Ios driver doesn't support xcode version 8.0
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME,"XCUITest");
capabilities.setCapability("realDeviceLogger", "/usr/local/lib/node_modules/deviceconsole/deviceconsole");
capabilities.setCapability(MobileCapabilityType.NO_RESET, true);
capabilities.setCapability(MobileCapabilityType.FULL_RESET, false);
capabilities.setCapability("xcodeConfigfile", "/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Configurations/ProjectSettings.xcconfig");
capabilities.setCapability("autoDismissAlerts", false);
AppiumFactory appiumFactory=new AppiumFactory();
appiumFactory.setiOSDriver1(new URL(Constant.SERVER1_ADRESS), capabilities);

Here's the full logs of appium server: https://gist.github.com/jeangb/904a7fcd0077f8e342fef7baf3811280 I saw Appium Server is trying to build the WDA agent with the command

xcodebuild build test -project /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=e75c0085c74a872846772a6b2ee56a86849a4d92 -configuration Debug

so I've been executed this command and here's the log it give me: https://gist.github.com/jeangb/c6c9b2b28e4620f426137f4da60091fe.

And when I launch the "build an then test the current scheme" of the runner target of the Xcode project (WDA), I've got this:

dyld: Library not loaded: @rpath/XCTest.framework/XCTest
  Referenced from: /var/containers/Bundle/Application/BBFB42C4-6E64-494A-AE2B-0E45C4FF2E8F/WebDriverAgentRunner-Runner.app/XCTRunner
  Reason: no suitable image found.  Did find:
	/private/var/containers/Bundle/Application/BBFB42C4-6E64-494A-AE2B-0E45C4FF2E8F/WebDriverAgentRunner-Runner.app/Frameworks/XCTest.framework/XCTest: mmap() errno=1 validating first page of '/private/var/containers/Bundle/Application/BBFB42C4-6E64-494A-AE2B-0E45C4FF2E8F/WebDriverAgentRunner-Runner.app/Frameworks/XCTest.framework/XCTest'
	/private/var/containers/Bundle/Application/BBFB42C4-6E64-494A-AE2B-0E45C4FF2E8F/WebDriverAgentRunner-Runner.app/Frameworks/XCTest.framework/XCTest: mmap() errno=1 validating first page of '/private/var/containers/Bundle/Application/BBFB42C4-6E64-494A-AE2B-0E45C4FF2E8F/WebDriverAgentRunner-Runner.app/Frameworks/XCTest.framework/XCTest'
(lldb) 

It manages to launch WebDriverAgent on the phone but screen is black.

Can you help me ?

jeangb avatar Dec 13 '16 14:12 jeangb

please update libimobiledevice

pavanbachu0604 avatar Dec 13 '16 14:12 pavanbachu0604

What happens when you run idevicedate -u e75c0085c74a872846772a6b2ee56a86849a4d92?

imurchie avatar Dec 13 '16 15:12 imurchie

@pavanbachu0604, I did "brew upgrade libimobiledevice" and got "Error: libimobiledevice 1.2.0 already installed". Nothing changed when I launched the tests.

jeangb avatar Dec 13 '16 15:12 jeangb

@pengboZheng I'm very sorry to hear that... can others confirm that ? what will work so ?

@imurchie : I got "ERROR: Could not connect to lockdownd, error code -21" when executing your command.

jeangb avatar Dec 13 '16 15:12 jeangb

brew install libimobiledevice --HEAD.

You can also get around it by running sudo chmod 777 /var/db/lockdown.

imurchie avatar Dec 13 '16 15:12 imurchie

~ $  brew install libimobiledevice@HEAD
Updating Homebrew...
Error: No available formula with the name "libimobiledevice@head"
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
Error: No formulae found in taps.

pb-z avatar Dec 13 '16 15:12 pb-z

@imurchie @pengboZheng when doing brew install libimobiledevice@HEAD I got the same logs than pengboZheng ones. But after using "sudo chmod 777 /var/db/lockdown", I launched the tests and logs from appium server are different: I got the famous "[XCUITest] xcodebuild exited with code '65' and signal 'null'" error and the same error than Xcode too : "[Xcode] dyld: Library not loaded: @rpath/XCTest.framework/XCTest". Full logs here: https://gist.github.com/jeangb/a5872e360996c61b0ffb00e61d48e44b

jeangb avatar Dec 13 '16 15:12 jeangb

@jeangb based on your log, seems you need to follow "Manual configuration alternative" in https://github.com/appium/appium-xcuitest-driver

pb-z avatar Dec 13 '16 16:12 pb-z

It should be brew install libimobiledevice --HEAD

pavanbachu0604 avatar Dec 13 '16 16:12 pavanbachu0604

@pengboZheng I'm doing this but I'm blocked at "sh ./Scripts/bootstrap.sh -d". I have sh: ./Scripts/bootstrap.sh: No such file or directory.

jeangb avatar Dec 13 '16 17:12 jeangb

Forgot my last message I was in the wrong directory

jeangb avatar Dec 13 '16 17:12 jeangb

So following "Manual configuration alternative" and executing "xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=udid' test" (with the real udid) I got this:

https://gist.github.com/jeangb/498c1c2f53209d1268cfec86dc69db7f

It's worse. Now I can't build no more the project on a real device.

jeangb avatar Dec 13 '16 17:12 jeangb

Suggestions:

  1. update node
  2. take a look at https://github.com/appium/appium/issues/7022 in details

By the way, xcuitest and iOS 9, 10 with Real Device working fine on my end.

pb-z avatar Dec 13 '16 19:12 pb-z

So the problem when Xcode couldn't execute the wda on a real device was because I executed the wrong target. Now when I build and test on the WebDriverAgentRunner I have the following error:

dyld: Library not loaded: @rpath/XCTest.framework/XCTest
  Referenced from: /var/containers/Bundle/Application/419931E5-8687-4A55-A434-E632AF6CC56C/WebDriverAgentRunner-Runner.app/XCTRunner
  Reason: no suitable image found.  Did find:
	/private/var/containers/Bundle/Application/419931E5-8687-4A55-A434-E632AF6CC56C/WebDriverAgentRunner-Runner.app/Frameworks/XCTest.framework/XCTest: mmap() errno=1 validating first page of '/private/var/containers/Bundle/Application/419931E5-8687-4A55-A434-E632AF6CC56C/WebDriverAgentRunner-Runner.app/Frameworks/XCTest.framework/XCTest'
	/private/var/containers/Bundle/Application/419931E5-8687-4A55-A434-E632AF6CC56C/WebDriverAgentRunner-Runner.app/Frameworks/XCTest.framework/XCTest: mmap() errno=1 validating first page of '/private/var/containers/Bundle/Application/419931E5-8687-4A55-A434-E632AF6CC56C/WebDriverAgentRunner-Runner.app/Frameworks/XCTest.framework/XCTest'

I had this error yesterday but when I was referencing this framework I still had this issue... @pengboZheng thanks, I'm looking at #7022

jeangb avatar Dec 14 '16 08:12 jeangb

red In xcode I noticed I have these products which aren't founded, is that a problem ?

jeangb avatar Dec 14 '16 09:12 jeangb

I got the exact same error with appium 1.6.3 while trying to execute the test cases on real device [XCUITest] Unable to start WebDriverAgent: Error: Command 'idevicedate -u udid' exited with code 255 idevicedate -u udid ERROR: Could not connect to lockdownd, error code -5 (I had tried with iPad Air 2 and iPad mini 4)

sudo chmod 777 /var/db/lockdown didn't help.

syedasadulhaq avatar Dec 14 '16 09:12 syedasadulhaq

@syedasadulhaq make sure the libimobiledevice is installed from HEAD branch

mykola-mokhnach avatar Dec 14 '16 10:12 mykola-mokhnach

I experience the same issue.

Environment

  • Appium version (or git revision) that exhibits the issue: 1.6.3
  • Desktop OS/version used to run Appium: 10.12.1
  • Node.js version (unless using Appium.app|exe): v7.0.0
  • Mobile platform/version under test: iOS 9.3.4 (13G35)
  • Real device or emulator/simulator: Real Device (iPad Mini 2)
  • Appium CLI or Appium.app|exe: appium CLI (bash)
  • Xcode : Version 8.1 (8B62)

Capabilities

  • capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest");
  • capabilities.setCapability("realDeviceLogger", "/usr/local/lib/node_modules/deviceconsole/deviceconsole");
  • capabilities.setCapability("xcodeConfigFile", "~/Desktop/Appium.xcconfig"); capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "[DEVICE_NAME]");
  • capabilities.setCapability(MobileCapabilityType.UDID, "[UDID]");
  • capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "9.3");
  • capabilities.setCapability(IOSMobileCapabilityType.BUNDLE_ID, "[BUNDLE_ID]");

Log

[debug] [XCUITest] XCUITestDriver version: 2.4.2 [BaseDriver] Session created with session id: d7fabff1-d6d7-4e65-984a-ba7847c85899 [debug] [XCUITest] iOS SDK Version set to '10.1' [debug] [XCUITest] Available devices: [UDID] [debug] [XCUITest] Creating iDevice object with udid [UDID] [XCUITest] Determining device to run tests on: udid: '[UDID]', real device: true [debug] [iOSLog] Attempting iOS device log capture via libimobiledevice idevicesyslog [debug] [iOSLog] Found idevicesyslog: '/usr/local/bin/idevicesyslog' [XCUITest] Setting up real device [XCUITest] Using WDA path: '~/appium-1.6.3/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent' [XCUITest] Using WDA agent: '~/appium-1.6.3/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj' [XCUITest] Launching WebDriverAgent on the device [debug] [XCUITest] Carthage found: /usr/local/bin/carthage [debug] [XCUITest] Killing hanging processes [debug] [XCUITest] Using real device logger '/usr/local/lib/node_modules/deviceconsole/deviceconsole' [debug] [XCUITest] Using Xcode configuration file: '~/appium-1.6.3/Appium.xcconfig' [debug] [XCUITest] Beginning test with command 'xcodebuild build test -project ~/appium-1.6.3/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=8457b818646c3089a8ddd896bcc5155c755ea5a7 -configuration Debug -xcconfig ~/Desktop/Appium.xcconfig' in directory '~/appium-1.6.3/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent' [XCUITest] Unable to start WebDriverAgent: Error: Command 'idevicedate -u [UDID]' exited with code 255 [XCUITest] Unable to start WebDriverAgent: Error: Command 'idevicedate -u [UDID]' exited with code 255 [XCUITest] Shutting down sub-processes [debug] [XCUITest] Running ios real device reset flow [debug] [XCUITest] Resetting simulator [debug] [iOSLog] Stopping iOS log capture [MJSONWP] Encountered internal error running command: undefined [HTTP] <-- POST /wd/hub/session 500 1634 ms - 262

mstrelex avatar Dec 14 '16 10:12 mstrelex

I give up. I'm starting to loose my mind on this.

jeangb avatar Dec 14 '16 11:12 jeangb

@mykola-mokhnach: brew install libimobiledevice --HEAD

Warning: libimobiledevice-1.2.0 already installed Warning: You are using OS X 10.12. We do not provide support for this pre-release version. You may encounter build failures or other breakages.

syedasadulhaq avatar Dec 14 '16 11:12 syedasadulhaq