ios – 在使用Cocoapods的项目中执行单元测试时,“类X都在两者中实现”

ios – 在使用Cocoapods的项目中执行单元测试时,“类X都在两者中实现”,第1张

概述我为使用 Cocoapods的现有项目添加了一个单元测试目标. 当我开始测试它运行iOS模拟器时,我在Xcode的控制台上发出了一堆警告: Class PodsDummy_Pods is implemented in both /Users/me/Library/Developer/CoreSimulator/Devices/604372F1-E934-445C-B8F6-3D8C86AA8E41 我为使用 Cocoapods的现有项目添加了一个单元测试目标.

当我开始测试它运行iOS模拟器时,我在Xcode的控制台上发出了一堆警告:

Class PodsDummy_Pods is implemented in both
/Users/me/library/Developer/CoreSimulator/Devices/604372F1-E934-445C-B8F6-3D8C86AA8E41/data/Containers/Bundle/Application/2A1BCAE6-5127-4288-B0E7-15588A1C09D1/MyAPP..app/MyApp.
and
/Users/me/library/Developer/Xcode/DerivedData/MyApp-fzjqljiyaapspvaylhszcbkhtijd/Build/Products/DeBUG-iphonesimulator/MyAppTests.xctest/MyAppTests.
One of the two will be used. Which one is undefined.

对于我的项目使用的窗格中包含的每个类,都会显示此错误消息.

最后,该项目抛出一个EXC_BAD_ACCESS

当我在Xcode的控制台中输入bt时,这个错误就像一个无限循环:

frame #130498: 0x000000012626e897
MyAppTests`___lldb_unnamed_function42$$MyAppTests + 135

有什么建议吗?

解决方法 终于找到了解决这个问题的方法!在我这边,我的swift框架单元测试存在这个问题.我的Podfile看起来像这样:

def import_gtm  send :pod,'GoogleTagManager','~> 5.0.8'endtarget 'MyFramework' do  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks  use_frameworks!  # Pods for MyFramework  import_gtmendtarget 'MyFrameworkTests' do  use_frameworks!  # Pods for testingend

虽然我的测试正确执行,但我有大量的日志,就像OP一样.在阅读了这个Github issue后,我更改了我的Podfile以获取以下内容:

def import_gtm  send :pod,'~> 5.0.8'endtarget 'MyFramework' do  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks  use_frameworks!  # Pods for MyFramework  import_gtm  target 'MyFrameworkTests' do    inherit! :search_paths  endend

我终于摆脱了所有这些警告日志!尝试在重建之前清理(cmd alt shift K)或删除DerivedData文件夹内容:

rm -rf ~/library/Developer/Xcode/DerivedData/*

我希望这有帮助 !

总结

以上是内存溢出为你收集整理的ios – 在使用Cocoapods的项目中执行单元测试时,“类X都在两者中实现”全部内容,希望文章能够帮你解决ios – 在使用Cocoapods的项目中执行单元测试时,“类X都在两者中实现”所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1054319.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-25
下一篇2022-05-25

发表评论

登录后才能评论

评论列表(0条)

    保存