You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Appium1.22搭配Xcode13.4.1时WDA卸载后无法重装,报xcodebuild错误码65

问题描述

在最新Mac设备上使用Appium 1.22版本,因最新版Xcode不被Appium支持,选用Xcode 13.4.1,使用非付费苹果个人账号。运行WebDriverAgent(WDA)时可将其安装到模拟器,但启动iOS应用后WDA被卸载且无法重新安装,随后出现错误:

Unable to launch WebDriverAgent because of xcodebuild failure:
xcodebuild failed with code 65

完整错误信息如下:

org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details.

原始错误:处理命令时发生未知服务器端错误。原始错误:无法启动WebDriverAgent,原因是xcodebuild失败:xcodebuild返回代码65

xcodebuild error message:



Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'

System info: host: '192.168.1.4', ip: 'fe80:0:0:0:400:de8d:f8ab:9871%en0', os.name: 'Mac OS X', os.arch:

'x86_64', os.version: '10.16', java.version: '1.8.0_211'

Driver info: driver.version: IOSDriver

remote stacktrace: UnknownError: 处理命令时发生未知服务器端错误。原始错误:无法启动WebDriverAgent,原因是xcodebuild失败:xcodebuild返回代码65

xcodebuild error message:

at getResponseForW3CError (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:804:9)

at asyncHandler (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:380:37)

Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'

System info: host: '192.168.1.4', ip: 'fe80:0:0:0:400:de8d:f8ab:9871%en0', os.name: 'Mac OS X', os.arch:

'x86_64', os.version: '10.16', java.version: '1.8.0_211'

Driver info: driver.version: IOSDriver

at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:216)

at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:225)

at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:250)

at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)

at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:41)

at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)

at io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1)

at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)

at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:363)

at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131)

at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:37)

at io.appium.java_client.AppiumDriver.(AppiumDriver.java:89)

at io.appium.java_client.AppiumDriver.(AppiumDriver.java:99)

at io.appium.java_client.ios.IOSDriver.(IOSDriver.java:90)

at com.qa.utils.DriverManager.initializeDriver(DriverManager.java:34)

at com.qa.runners.MyRunnerTest.initialize(MyRunnerTest.java:41)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)

at org.junit.internal.runners.statements.RunBefores.invokeMethod(RunBefores.java:33)

at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)

at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)

at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)

at org.junit.runners.ParentRunner.run(ParentRunner.java:413)

at org.junit.runner.JUnitCore.run(JUnitCore.java:137)

at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)

at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)

at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)

at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)

at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)

at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

Caused by: java.lang.reflect.InvocationTargetException

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:193)

... 34 more

Caused by: org.openqa.selenium.WebDriverException: 处理命令时发生未知服务器端错误。原始错误:无法启动WebDriverAgent,原因是xcodebuild失败:xcodebuild返回代码65

xcodebuild error message:



Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'

System info: host: '192.168.1.4', ip: 'fe80:0:0:0:400:de8d:f8ab:9871%en0', os.name: 'Mac OS X', os.arch:

'x86_64', os.version: '10.16', java.version: '1.8.0_211'

Driver info: driver.version: IOSDriver

remote stacktrace: UnknownError: 处理命令时发生未知服务器端错误。原始错误:无法启动WebDriverAgent,原因是xcodebuild失败:xcodebuild返回代码65

xcodebuild error message:

at getResponseForW3CError (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:804:9)

at asyncHandler (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:380:37)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)

at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)

at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)

at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)

at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)

at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)

at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)

at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)

at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)

at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)

at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)

at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)

at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)

解决方案

1. 手动预安装并信任WDA

  • 打开Xcode,定位到Appium自带的WDA项目,路径通常为:/usr/local/lib/node_modules/appium/node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj
  • 选择WebDriverAgentRunner target,进入Signing & Capabilities面板,设置你的个人开发者账号,开启自动管理签名,修改Bundle ID为唯一值(比如在默认ID后添加个人标识后缀)
  • 选中目标模拟器,点击Xcode运行按钮,将WDA安装到模拟器
  • 打开模拟器的「设置」→「通用」→「VPN与设备管理」,找到你的开发者账号并完成信任操作

2. 配置Appium启动参数

启动Appium时添加以下参数,避免自动卸载重装WDA:

appium --default-capabilities '{"xcodeOrgId": "你的团队ID", "xcodeSigningId": "iPhone Developer", "usePrebuiltWDA": true, "noReset": true}'

或者在测试代码的DesiredCapabilities中设置:

capabilities.setCapability("xcodeOrgId", "你的团队ID");
capabilities.setCapability("xcodeSigningId", "iPhone Developer");
capabilities.setCapability("usePrebuiltWDA", true);
capabilities.setCapability("noReset", true);
  • usePrebuiltWDA: 复用预编译的WDA,跳过每次启动时的重新编译流程
  • noReset: 不重置应用状态,保留已安装的WDA

3. 匹配Xcode命令行工具版本

确保Xcode命令行工具与Xcode 13.4.1版本一致:

xcode-select -s /Applications/Xcode_13.4.1.app/Contents/Developer

4. 清理WDA编译缓存

删除旧的WDA编译缓存,重新编译:

rm -rf ~/Library/Developer/Xcode/DerivedData/WebDriverAgent*

内容的提问来源于stack exchange,提问作者Amit Verma

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.31 00:01:38