ios - 无法加载 UITests 包,因为它已损坏或缺少必要的资源。尝试重新安装 bundle

标签 ios swift travis-ci uitest

由于以下错误,我无法运行我的测试用例:

  • 无法加载“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设置中删除这一行的原因:

MyAppUITests build settings

之后运行 pod deintegrate && pod install 然后问题就消失了。 可能对于具有更多依赖项的项目(如 here ),您需要使用其他解决方案。

关于ios - 无法加载 UITests 包,因为它已损坏或缺少必要的资源。尝试重新安装 bundle ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40480503/

相关文章:

java - Travis CI 上的 Retrolambda

node.js - Google App Engine 和 Travis CI 上的 NodeJS 环境变量

travis-ci - 重命名 repo 破坏了 travis

ios - 更改 UIView 的 alpha 会影响字体不透明度

ios - 适用于 Swift iOS native 应用程序的 SignalR

ios - 添加和保存新联系人到地址簿

ios - 如何将圆形动画应用于单元格?

ios - 具有纯色的 UINavigationBar - ios 7

ios - iPhone中的照片访问API是否允许从应用程序中删除照片?

ios - 没有数组从父应用程序发送到 Watch 应用程序