The bundle UITests couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle

user2273146 picture user2273146 · Nov 8, 2016 · Viewed 25.2k times · Source

I can't run my test case due to this following errors :

  • The bundle “UITests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
  • Library not loaded: @rpath/Alamofire.framework/Alamofire.
  • Reason: image not found

Try searching and solving since two days but couldn't get through this issue can someone please help.

Answer

Roman Podymov picture Roman Podymov · Sep 16, 2018

I was able to reproduce this issue with the project generated by Xcode 10.1. I used Swift 4.2 and CocoaPods as a dependency manager. I had the following 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

Then I removed use_frameworks!, see this link for more details:

# 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

I also received some warnings like this:

[!] 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.

That's why I removed this line from the MyAppUITests build settings:

MyAppUITests build settings

After that run pod deintegrate && pod install and then the problem disappeared. Probably for projects with more dependencies (like here) you need to use another solution.