由于以下错误,我无法运行我的测试用例:
- 无法加载“UITests”包,因为它已损坏或缺少必要的资源。尝试重新安装 bundle 。
- 库未加载:@rpath/Alamofire.framework/Alamofire。
- 原因:找不到图片
这两天尝试搜索和解决,但无法解决此问题,请有人帮忙。
最佳答案
我能够使用 Xcode 10.1 生成的项目重现此问题。我使用 Swift 4.2 和 CocoaPods 1.10.0 作为依赖项管理器。我有以下 Podfile:
# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'
target 'MyApp' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for MyApp
pod 'Alamofire', '4.8.1'
target 'MyAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'MyAppUITests' do
inherit! :search_paths
# Pods for testing
end
end
然后我删除了 use_frameworks!
,参见 this link了解更多详情:
# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'
target 'MyApp' do
# Pods for MyApp
pod 'Alamofire', '4.8.1'
target 'MyAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'MyAppUITests' do
inherit! :search_paths
# Pods for testing
end
end
我也收到了一些这样的警告:
[!] The `MyAppUITests [Debug]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-MyApp-MyAppUITests/Pods-MyApp-MyAppUITests.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
这就是我从 MyAppUITests build设置中删除这一行的原因:
之后运行 pod deintegrate && pod install
然后问题就消失了。
可能对于具有更多依赖项的项目(如 here ),您需要使用其他解决方案。
关于ios - 无法加载 UITests 包,因为它已损坏或缺少必要的资源。尝试重新安装 bundle ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40480503/