我为 Real iOS 设备设置了 Appium,无法启动 WebDriverAgent,因为 xcodebuild 失败,代码为 65

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

我正在尝试 运行 Appium 在真正的 iOS 设备上。我已经能够在 android 上成功地 运行 它,但是当我尝试 运行ning 用于 iOS 时,我得到了错误。这是我的环境:

Appium v1.8.0

iPhone SE 11.2.6

Xcode 9.3.1

我听说 error 65 通常是由于使用免费帐户引起的,但我正在为我们的开发团队使用 xcodeSigningId

我宁愿自动配置工作,但我还是尝试了手动配置,但我认为我做对了。我遵循了这个网站的步骤:

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

这个站点的这个命令对我不起作用:

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

此命令不起作用,无论是在我为 phone 的 uid 更改 id 之前还是之后。我收到错误:

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

但我不确定这个密钥应该从哪里来,也不知道如何格式化它。

我也尝试重新下载各种依赖项,确保我没有使用 sudo。这没有帮助。

我在下面包含了完整的 Appium 日志:

[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]

我在这个问题上卡了这么多天。任何帮助将不胜感激。

您遇到的错误是 iOS/real 设备上 Appium 最常见的错误。

强烈建议使用官方Appium文档iOS real device setup

博文不错,但通常不维护,因此可能包含过时信息。

按照文档中的步骤进行操作并确保您拥有有效的 Apple 开发者帐户,您需要使用它来签署 WebDriverAgent。

这是最棘手的部分,如果您的帐户设置正确 - 过程会很顺利。

原来我的问题是因为在我之前拥有这台电脑的人安装了一个过期的苹果开发者证书。一旦我从钥匙串中删除它,appium 就可以 运行 on iOS.

感谢 dmle 为我指明了正确的方向。

就我而言(appium 1.19.1iOS 14.2Xcode 12.2node v15.3.0),我通过更新 WebDriverAgent.xcodeproj 的签名设置解决了这个问题(在 /usr/local/lib/node_modules/appium/node_modules/appium-webdriveragent,注意路径可能会改变)。您必须为每个目标设置签名策略(IntegrationApp 等等)。您可能还需要为他们 select 一个 Team

基本上就是让代码签名生效。

最后,别忘了在 desired_capabilitiesxcodeSigningId。因为你已经设置好了。