记录一个UITests Failed 的问题:The bundle “XXXUITests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
环境
Mac OS: 10.15.5
Xcode: Version 11.5 (11E608c)
CocoaPod: 1.9.3
具体log
~ - Running tests...
~ The bundle “XXXUITests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
~ (
dlopen_preflight
(/Users/xxx/Library/Developer/Xcode/DerivedData/XXX-fmdyesowgzsltadmwckhyobwzodi/Build/Products/Debug-iphonesimulator/XXXUITests-Runner.app/PlugIns/XXXUITests.xctest/XXXUITests): Library not loaded: @rpath/AFNetworking.framework/AFNetworking
Referenced from: /Users/xxx/Library/Developer/Xcode/DerivedData/XXX-fmdyesowgzsltadmwckhyobwzodi/Build/Products/Debug-iphonesimulator/XXXUITests-Runner.app/PlugIns/XXXUITests.xctest/XXXUITests
Reason: image not found)
问题过程
在进行FastLane自动化过程中,使用自动屏幕快照过程中,需要写测试用例。所以问题就出现了!
问题原因
项目是混编的项目,其中有Swift,然后就涉及到了Swift历史问题,静态库与动态库的问题。
解决方案
Podfile文件中,
方案一:将use_frameworks! 删除
方案二:将use_frameworks! 替换为 use_modular_headers!
一直没有关过CocoaPods有什么新特性,这就掉坑了!
参考链接
https://stackoverflow.com/questions/40480503/the-bundle-uitests-couldn-t-be-loaded-because-it-is-damaged-or-missing-necessary/52355417#52355417
https://stackoverflow.com/questions/41210249/why-do-we-use-use-frameworks-in-cocoapods/49469205#49469205
https://stackoverflow.com/questions/54365549/the-bundle-uitests-couldn-t-be-loadedbecause-it-is-damaged-or-missing-necessary