iOS 测试 webDriverAgent: A collection of solutions for "dyld :Library not loaded: @rpath/XCTest.framework/XCTest"

songzx · 2019年02月27日 · 1126 次阅读

webDriverAgent: A collection of solutions for "dyld :Library not loaded: @rpath/XCTest.framework/XCTest"

(不清楚 xcode 的使用及 ios 开发相关,只为描述问题,盗图)

问题场景


机器环境

  • Macmini
  • Mac os ver : 10.14
  • Xcoed ver : 10.1
  • 网络状况:无网络

使用状况

github 工程地址:https://github.com/facebook/WebDriverAgent
直接使用 github 上的 WebDriverAgent 工程与 Appium 无关

WebDriverAgent 工程已在其他电脑上做过官网的 "Getting Started"

xcode Test 日志输出如下:

说明工程正常无误,可以使用,现拷贝工程至其他电脑使用。

错误输出
执行 xcode Test 后 build succeed, 并且安装 wda 至手机,但是 testing 时错误,输出日志如下:
dyld: Library not loaded: @rpath/XCTest.framework/XCTest
Referenced from: /var/containers/Bundle/Application/2475BEE5-0F21-4D52-9936-1CB0659F70C4/WebDriverAgentRunner-Runner.app/XCTRunner
Reason: no suitable image found. Did find:
/private/var/containers/Bundle/Application/2475BEE5-0F21-4D52-9936-1CB0659F70C4/WebDriverAgentRunner-Runner.app/Frameworks/XCTest.framework/XCTest: code signing blocked mmap() of '/private/var/containers/Bundle/Application/2475BEE5-0F21-4D52-9936-1CB0659F70C4/WebDriverAgentRunner-Runner.app/Frameworks/XCTest.framework/XCTest'
/private/var/containers/Bundle/Application/2475BEE5-0F21-4D52-9936-1CB0659F70C4/WebDriverAgentRunner-Runner.app/Frameworks/XCTest.framework/XCTest: code signing blocked mmap() of '/private/var/containers/Bundle/Application/2475BEE5-0F21-4D52-9936-1CB0659F70C4/WebDriverAgentRunner-Runner.app/Frameworks/XCTest.framework/XCTest'

问题分析


网上有很多人都遇到了这个问题,且解决的方案多样,作者大多同样不理解 ios 开发及 xcode。在修复的过程中尝试了多种方式均无效,所以整理浏览资料合集。

由于工程是拷贝而来, 且验证过工程文件是可以正常 Test 的,猜测是由于系统环境等导致的问题。选择以下方式解决问题:

  1. 删除无法使用的旧工程
  2. 拷贝新工程至电脑
  3. 直接使用 xcode 打开新工程后,什么都不要修改(请注意 - 不要修改任何东西,遇到情况,修改后 clean 将不起作用)
  4. 执行 xcode 菜单中的选项 Product -> Clean Build Folder
  5. 根据需求,选择签名证书,更改 Bundle ID, 修改工程文件
  6. 执行 xcode Test , ok 可以正常运行了

该方案感谢:

拯救了被反复摩擦的我

其他解决方案


(不针对 WebDriverAgent 工程)
方案 1:
如果你能确定自己的工程不要使用 XCTest 的话,
在工程 -> targets -> Bulid Phases -> Complie Sources -> 搜索 test,如果有结果,删除即可


方案 2:
查看自己的工程是不是缺失了这个库,在如下图处搜索报错的库

如果没有拖动添加


缺少 XCTest 请在Build Phases -> Link Binary With Libraries
中添加


方案 3
修改 Runpath Search Paths(个人认为该方案是由于 xcode 安装引起的)
xcode Build Settings->Runpath Search Paths
键入 xcode 的路径 eg:/Applications/Xcode.app/Contents/Developer/Library/Frameworks/


方案 4
使用的签名证书不能设置为 “始终信任”,设置为 “系统默认”
新版本 Xcode Build Setting->Build Option->Always Embed Swift Standard Libraries设置为 yes。
完美解决! 


方案 5
关于 appium 的 这个兄弟比较惨,冗长难以阅读,解决方法就是放大招,重装。上图上链接:


链接如下:http://discuss.appium.io/t/error-dyld-library-not-loaded-rpath-xctest-framework-xctest-displays-when-deploying-webdriveragent-into-real-device/14234/42


方案 6
关于 appium 的,上链接:https://testerhome.com/topics/9189


方案 7
关机流

  • 在手机数据线链接状态下,关闭手机,并重新打开
  • 关闭电脑后启动

参考资料


https://testerhome.com 中搜索 dyld:Library not loaded: @rpath/XCTest.framework/XCTest

https://github.com/facebook/WebDriverAgent/issues/664
https://github.com/facebook/WebDriverAgent/issues/424
https://www.jianshu.com/p/b6b2fc31eb2a
https://blog.csdn.net/gaomingyangc/article/details/55657054
https://blog.csdn.net/u010696783/article/details/47778881

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册