Search code examples
iosxcodeappiumxcuitestapple-developer

I set up Appium for Real iOS device, Unable to launch WebDriverAgent because xcodebuild failed with code 65


I am trying to run Appium on a real iOS device. I have been able to successfully run it on android, but when I try running for iOS I get the error. Here is my environment:

Appium v1.8.0

iPhone SE 11.2.6

Xcode 9.3.1

I’ve read that error 65 is often caused by using a free account, but I’m using the xcodeSigningId for our development team.

I would rather the automatic configuration work, but I tried the manual configuration anyway, but I don’t think I did it right. I followed the steps from this site:

https://huddle.eurostarsoftwaretesting.com/how-to-set-up-appium-on-a-mac-fast-java/

This command from this site did not work for me:

xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination ‘id=af916cc5486cf9cb85ddde19f97949ecd6c62c66’ test

This command does not work, neither before nor after I changed the id out for my phone’s uid. I get the error:

option ‘Destination’ requires at least one parameter of the form ‘key=value'

but I’m not sure where this key is supposed to come from or how exactly to format it.

I’ve also tried redownloading various dependencies, making sure I didn’t use sudo. This didn’t help.

I’ve included the full Appium log below:

[Appium] Welcome to Appium v1.8.0
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> GET /wd/hub/sessions
[HTTP] {}
[MJSONWP] Calling AppiumDriver.getSessions() with args: []
[MJSONWP] Responding to client with driver.getSessions() result: []
[HTTP] <-- GET /wd/hub/sessions 200 7 ms - 40
[HTTP] 
[HTTP] --> POST /wd/hub/session
[HTTP] {"desiredCapabilities":{"appActivity":"REDACTED.LaunchActivity","automationName":"XCUITest","bundleId":"REDACTED","deviceName":"REDACTED iPhone","launchTimeout":20000,"noReset":true,"platformName":"iOS","platformVersion":"11.2.6","showXcodeLog":true,"udid":"REDACTED","xcodeOrgId":"9BKN37UJM1","xcodeSigningId":"iPhone Developer","newCommandTimeout":0,"connectHardwareKeyboard":true}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{"appActivity":"REDACTED.LaunchActivity","automationName":"XCUITest","bundleId":"REDACTED","deviceName":"REDACTED iPhone","launchTimeout":20000,"noReset":true,"platformName":"iOS","platformVersion":"11.2.6","showXcodeLog":true,"udid":"REDACTED","xcodeOrgId":"9BKN37UJM1","xcodeSigningId":"iPhone Developer","newCommandTimeout":0,"connectHardwareKeyboard":true},null,null]
[BaseDriver] Event 'newSessionRequested' logged at 1526490334005 (13:05:34 GMT-0400 (EDT))
[Appium] Creating new XCUITestDriver (v2.79.3) session
[Appium] Capabilities:
[Appium] appActivity: REDACTED.LaunchActivity
[Appium] automationName: XCUITest
[Appium] bundleId: REDACTED
[Appium] deviceName: REDACTED iPhone
[Appium] launchTimeout: 20000
[Appium] noReset: true
[Appium] platformName: iOS
[Appium] platformVersion: 11.2.6
[Appium] showXcodeLog: true
[Appium] udid: REDACTED
[Appium] xcodeOrgId: 9BKN37UJM1
[Appium] xcodeSigningId: iPhone Developer
[Appium] newCommandTimeout: 0
[Appium] connectHardwareKeyboard: true
[BaseDriver] Creating session with MJSONWP desired capabilities: {"appActivity":"com....
[BaseDriver] The following capabilities were provided, but are not recognized by appium: appActivity.
[BaseDriver] Session created with session id: d25159cd-17b7-42d1-ab33-6083ab63290d
[XCUITest] Current user: 'REDACTED'
[XCUITest] Xcode version set to '9.3.1' (tools v9.3.0.0.1.1521514116)
[XCUITest] iOS SDK Version set to '11.3'
[BaseDriver] Event 'xcodeDetailsRetrieved' logged at 1526490334208 (13:05:34 GMT-0400 (EDT))
[XCUITest] Available devices: REDACTED, REDACTED
[XCUITest] Creating iDevice object with udid 'REDACTED'
[XCUITest] Determining device to run tests on: udid: 'REDACTED', real device: true
[BaseDriver] Event 'appConfigured' logged at 1526490334333 (13:05:34 GMT-0400 (EDT))
[BaseDriver] Event 'resetStarted' logged at 1526490334334 (13:05:34 GMT-0400 (EDT))
[XCUITest] Reset: fullReset not set. Leaving as is
[BaseDriver] Event 'resetComplete' logged at 1526490334334 (13:05:34 GMT-0400 (EDT))
[iOSLog] Attempting iOS device log capture via libimobiledevice idevicesyslog
[iOSLog] Starting iOS device log capture with: 'idevicesyslog'
[BaseDriver] Event 'logCaptureStarted' logged at 1526490334823 (13:05:34 GMT-0400 (EDT))
[XCUITest] Setting up real device
[XCUITest] Using WDA path: '/Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/WebDriverAgent'
[XCUITest] Using WDA agent: '/Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj'
[XCUITest] No obsolete cached processes from previous WDA sessions listening on port 8100 have been found
[JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[XCUITest] WDA is not listening at 'http://localhost:8100/'
[BaseDriver] Event 'wdaStartAttempted' logged at 1526490335360 (13:05:35 GMT-0400 (EDT))
[XCUITest] Launching WebDriverAgent on the device
[XCUITest] Carthage found: '/usr/local/bin/carthage'
[XCUITest] Killing running processes 'xcodebuild.*REDACTED, iproxy 8100' for the device REDACTED...
[XCUITest] 'pgrep -nif xcodebuild.*REDACTED' didn't detect any matching processes. Return code: 1
[XCUITest] 'pgrep -nif iproxy 8100' didn't detect any matching processes. Return code: 1
[XCUITest] Starting iproxy to forward traffic from local port 8100 to device port 8100 over USB
[XCUITest] Using Xcode 9.3.1, so fixing WDA codebase
[XCUITest] Generating xcode config file for orgId '9BKN37UJM1' and signingId 'iPhone Developer'
[XCUITest] Writing xcode config file to /var/folders/_r/0dsmcvp57ld6qh2cw41rfpb5b01q6j/T/2018416-1174-hzu0k9.6j78m/appium-temp.xcconfig
[XCUITest] Using Xcode configuration file: '/var/folders/_r/0dsmcvp57ld6qh2cw41rfpb5b01q6j/T/2018416-1174-hzu0k9.6j78m/appium-temp.xcconfig'
[XCUITest] Beginning test with command 'xcodebuild build-for-testing test-without-building -project /Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=REDACTED IPHONEOS_DEPLOYMENT_TARGET=11.2 -xcconfig /var/folders/_r/0dsmcvp57ld6qh2cw41rfpb5b01q6j/T/2018416-1174-hzu0k9.6j78m/appium-temp.xcconfig' in directory '/Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/WebDriverAgent'
[XCUITest] Output from xcodebuild will be logged. To change this, use 'showXcodeLog' desired capability
[Xcode] Build settings from command line:
[Xcode] IPHONEOS_DEPLOYMENT_TARGET = 11.2
[Xcode] 
[Xcode] 
[XCUITest] Waiting up to 60000ms for WebDriverAgent to start
[JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[Xcode] Build settings from configuration file '/var/folders/_r/0dsmcvp57ld6qh2cw41rfpb5b01q6j/T/2018416-1174-hzu0k9.6j78m/appium-temp.xcconfig':
[Xcode] CODE_SIGN_IDENTITY = iPhone Developer
[Xcode] DEVELOPMENT_TEAM = 9BKN37UJM1
[Xcode] 
[Xcode] 
[JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[Xcode] === BUILD TARGET WebDriverAgentLib OF PROJECT WebDriverAgent WITH CONFIGURATION Debug ===
[Xcode] 
[Xcode] 
[Xcode] Check dependencies
[Xcode] 
[JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[Xcode] Code Signing Error: No signing certificate "iOS Development" found: No "iOS Development" signing certificate matching team ID "9BKN37UJM1" with a private key was found.
[Xcode] 
[Xcode] 
[Xcode] 
[Xcode] ** TEST BUILD FAILED **
[Xcode] 
[Xcode] 
[Xcode] The following build commands failed:
[Xcode] Check dependencies
[Xcode] (1 failure)
[Xcode] 
[XCUITest] Log file for xcodebuild test: /var/folders/_r/0dsmcvp57ld6qh2cw41rfpb5b01q6j/T/com.apple.dt.XCTest/IDETestRunSession-29AD789B-73D6-47D6-9F06-98DA13C08ED0/WebDriverAgentRunner-36675E5C-B052-43BE-BE0D-EE10F8069B48/Session-WebDriverAgentRunner-2018-05-16_130542-ZtN0wJ.log
[Xcode] 2018-05-16 13:05:42.541 xcodebuild[1254:44488] IDETestOperationsObserverDebug: Writing diagnostic log for test session to:
[Xcode] /var/folders/_r/0dsmcvp57ld6qh2cw41rfpb5b01q6j/T/com.apple.dt.XCTest/IDETestRunSession-29AD789B-73D6-47D6-9F06-98DA13C08ED0/WebDriverAgentRunner-36675E5C-B052-43BE-BE0D-EE10F8069B48/Session-WebDriverAgentRunner-2018-05-16_130542-ZtN0wJ.log
[Xcode] 
[Xcode] 2018-05-16 13:05:42.542 xcodebuild[1254:44485] [MT] IDETestOperationsObserverDebug: (DA8994EB-5B03-4B15-8ADD-F4241AF1ECD9) Beginning test session WebDriverAgentRunner-DA8994EB-5B03-4B15-8ADD-F4241AF1ECD9 at 2018-05-16 13:05:42.542 with Xcode 9E501 on target {
[Xcode] deviceSerialNumber: F17RH1X0H2XQ
[Xcode] identifier: REDACTED
[Xcode] deviceClass: iPhone
[Xcode] deviceName: REDACTED iPhone
[Xcode] deviceIdentifier: REDACTED
[Xcode] productVersion: 11.3
[Xcode] buildVersion: 15E216
[Xcode] deviceSoftwareVersion: 11.3 (15E216)
[Xcode] deviceArchitecture: arm64
[Xcode] deviceTotalCapacity: 12580106240
[Xcode] deviceAvailableCapacity: 6002483200
[Xcode] deviceIsTransient: NO
[Xcode] ignored: NO
[Xcode] deviceIsBusy: NO
[Xcode] deviceIsActivated: YES
[Xcode] deviceActivationState: Activated
[Xcode] isPasscodeLocked: NO
[Xcode] deviceType: 
[Xcode] supportedDeviceFamilies: (
[Xcode] 1
[Xcode] )
[Xcode] applications: (null)
[Xcode] provisioningProfiles: (null)
[Xcode] hasInternalSupport: NO
[Xcode] isSupportedOS: YES
[Xcode] developerDiskMountError: (null)
[Xcode] (null)
[Xcode] bootArgs: 
[Xcode] connected: yes
[Xcode] isWirelessEnabled: no
[Xcode] connectionType: direct
[Xcode] } (11.3 (15E216))
[Xcode] 
[Xcode] 2018-05-16 13:05:42.563 xcodebuild[1254:44485] Error Domain=NSCocoaErrorDomain Code=260 "The file “WebDriverAgentRunner-Runner.app” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Users/REDACTED/Library/Developer/Xcode/DerivedData/WebDriverAgent-cvqckynzuuktkogfpkkkgyompmoj/Build/Products/Debug-iphoneos/WebDriverAgentRunner-Runner.app, NSUnderlyingError=0x7fec30966a50 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
[Xcode] 
[Xcode] 2018-05-16 13:05:42.563 xcodebuild[1254:44485] 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, NSUnderlyingError=0x7fec31094440 {Error Domain=NSCocoaErrorDomain Code=260 "The file “WebDriverAgentRunner-Runner.app” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Users/REDACTED/Library/Developer/Xcode/DerivedData/WebDriverAgent-cvqckynzuuktkogfpkkkgyompmoj/Build/Products/Debug-iphoneos/WebDriverAgentRunner-Runner.app, NSUnderlyingError=0x7fec30966a50 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}}}
[Xcode] 
[Xcode] 
[Xcode] Testing failed:
[Xcode] No signing certificate "iOS Development" found: No "iOS Development" signing certificate matching team ID "9BKN37UJM1" with a private key was found.
[Xcode] Early unexpected exit, operation never finished bootstrapping - no restart will be attempted
[Xcode] ** TEST EXECUTE FAILED **
[Xcode] 
[Xcode] 
[XCUITest] xcodebuild exited with code '65' and signal 'null'
[Xcode] Contents of xcodebuild log file '/var/folders/_r/0dsmcvp57ld6qh2cw41rfpb5b01q6j/T/com.apple.dt.XCTest/IDETestRunSession-29AD789B-73D6-47D6-9F06-98DA13C08ED0/WebDriverAgentRunner-36675E5C-B052-43BE-BE0D-EE10F8069B48/Session-WebDriverAgentRunner-2018-05-16_130542-ZtN0wJ.log':
[Xcode] 13:05:42.542 xcodebuild[1254:44485] Beginning test session WebDriverAgentRunner-DA8994EB-5B03-4B15-8ADD-F4241AF1ECD9 at 2018-05-16 13:05:42.542 with Xcode 9E501 on target {
[Xcode] deviceSerialNumber: F17RH1X0H2XQ
[Xcode] identifier: REDACTED
[Xcode] deviceClass: iPhone
[Xcode] deviceName: REDACTED iPhone
[Xcode] deviceIdentifier: REDACTED
[Xcode] productVersion: 11.3
[Xcode] buildVersion: 15E216
[Xcode] deviceSoftwareVersion: 11.3 (15E216)
[Xcode] deviceArchitecture: arm64
[Xcode] deviceTotalCapacity: 12580106240
[Xcode] deviceAvailableCapacity: 6002483200
[Xcode] deviceIsTransient: NO
[Xcode] ignored: NO
[Xcode] deviceIsBusy: NO
[Xcode] deviceIsActivated: YES
[Xcode] deviceActivationState: Activated
[Xcode] isPasscodeLocked: NO
[Xcode] deviceType: 
[Xcode] supportedDeviceFamilies: (
[Xcode] 1
[Xcode] )
[Xcode] applications: (null)
[Xcode] provisioningProfiles: (null)
[Xcode] hasInternalSupport: NO
[Xcode] isSupportedOS: YES
[Xcode] developerDiskMountError: (null)
[Xcode] (null)
[Xcode] bootArgs: 
[Xcode] connected: yes
[Xcode] isWirelessEnabled: no
[Xcode] connectionType: direct
[Xcode] } (11.3 (15E216))
[Xcode] 13:05:42.543 xcodebuild[1254:44485] /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild
[Xcode] build-for-testing
[Xcode] test-without-building
[Xcode] -project
[Xcode] /Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj
[Xcode] -scheme
[Xcode] WebDriverAgentRunner
[Xcode] -destination
[Xcode] id=REDACTED
[Xcode] IPHONEOS_DEPLOYMENT_TARGET=11.2
[Xcode] -xcconfig
[Xcode] /var/folders/_r/0dsmcvp57ld6qh2cw41rfpb5b01q6j/T/2018416-1174-hzu0k9.6j78m/appium-temp.xcconfig
[Xcode] 13:05:42.543 xcodebuild[1254:44485] Launching with Xcode.IDEFoundation.Launcher.PosixSpawn
[Xcode] 13:05:42.546 xcodebuild[1254:44485] Test standard output and standard error is at /var/folders/_r/0dsmcvp57ld6qh2cw41rfpb5b01q6j/T/com.apple.dt.XCTest/IDETestRunSession-29AD789B-73D6-47D6-9F06-98DA13C08ED0/WebDriverAgentRunner-36675E5C-B052-43BE-BE0D-EE10F8069B48/StandardOutputAndStandardError.txt
[Xcode] 13:05:42.552 xcodebuild[1254:44485] Setting up test runner session
[Xcode] 13:05:42.554 xcodebuild[1254:44485] Launch session started.
[Xcode] 13:05:42.558 xcodebuild[1254:44485] Test operation failure: Launch session expired before checking in.
[Xcode] 13:05:42.558 xcodebuild[1254:44485] _finishWithError:Error Domain=IDETestOperationsObserverErrorDomain Code=5 "Launch session expired before checking in." UserInfo={NSLocalizedDescription=Launch session expired before checking in.}
[Xcode] 
[BaseDriver] Event 'wdaStartFailed' logged at 1526490342586 (13:05:42 GMT-0400 (EDT))
[XCUITest] Unable to launch WebDriverAgent because of xcodebuild failure: "xcodebuild failed with code 65". Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.
[XCUITest] Quitting and uninstalling WebDriverAgent, then retrying
[XCUITest] Shutting down sub-processes
[XCUITest] Shutting down iproxy process (pid 1252)
[XCUITest] iproxy exited with code 'null'
[XCUITest] Removing WDA application from device
[XCUITest] Error: Unable to launch WebDriverAgent because of xcodebuild failure: "xcodebuild failed with code 65". Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.
[XCUITest] at XCUITestDriver.quitAndUninstall$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/lib/driver.js:427:13)
[XCUITest] at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/node_modules/babel-runtime/regenerator/runtime.js:67:40)
[XCUITest] at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/node_modules/babel-runtime/regenerator/runtime.js:315:22)
[XCUITest] at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/node_modules/babel-runtime/regenerator/runtime.js:100:21)
[XCUITest] at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[XCUITest] at 
[XCUITest] Not clearing log files. Use `clearSystemFiles` capability to turn on.
[iOSLog] Stopping iOS log capture
[BaseDriver] Event 'newSessionStarted' logged at 1526490343881 (13:05:43 GMT-0400 (EDT))
[MJSONWP] Encountered internal error running command: Error: Unable to launch WebDriverAgent because of xcodebuild failure: "xcodebuild failed with code 65". Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.
[MJSONWP] at XCUITestDriver.quitAndUninstall$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/lib/driver.js:427:13)
[MJSONWP] at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/node_modules/babel-runtime/regenerator/runtime.js:67:40)
[MJSONWP] at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/node_modules/babel-runtime/regenerator/runtime.js:315:22)
[MJSONWP] at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/node_modules/babel-runtime/regenerator/runtime.js:100:21)
[MJSONWP] at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[MJSONWP] at 
[HTTP] <-- POST /wd/hub/session 500 9884 ms - 470
[HTTP]

I've been stuck on this problem for so many days. Any help would be greatly appreciated.


Solution

  • The error you get is the most common error with Appium on iOS/real device.

    Strongly suggest to use official Appium documentation: iOS real device setup

    Blog posts are good, but they are usually not maintained, so may contain outdated information.

    Follow the steps in documentation and make sure you have valid Apple developer account, you need to to sign WebDriverAgent with it.

    Thats the most tricky part, if your account is set properly - the process goes smoothly.