Search code examples
iosswiftxcodecocoapodsxcode-ui-testing

Xcode 10 UI Tests Reason: Image Not Found with Cocoapods


I'm trying to run a UI Test in my app but as soon as the simulator launches I get:

The bundle “AppUITests” couldn't be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.

2018-10-05 11:04:59.772078-0500 AppUITests-Runner[53273:1645870] (dlopen_preflight(/Users/John/Library/Developer/Xcode/DerivedData/app-ios-client-ewtlrcqcxoeiaudgmthymuhcuxfz/Build/Products/Debug-iphonesimulator/AppUITests-Runner.app/PlugIns/AppUITests.xctest/AppUITests): Library not loaded: @rpath/libswiftSwiftOnoneSupport.dylib Referenced from: /Users/John/Library/Developer/Xcode/DerivedData/app-ios-client-ewtlrcqcxoeiaudgmthymuhcuxfz/Build/Products/Debug-iphonesimulator/AppUITests-Runner.app/PlugIns/AppUITests.xctest/Frameworks/Alamofire.framework/Alamofire Reason: image not found)

My UITest is the template created by Xcode 10, I'm using Cocoapods 1.5.3 and Swift 4.2

My project structure:

  • Workspace
    • Custom Framework (The Podfile is here)
    • App A (Here I'm running the UITests)
    • App B

My podfile looks like this:

platform :ios, '10.0'

inhibit_all_warnings!
use_frameworks!

target 'App Library' do
    use_frameworks!

    pod 'Intercom'
    pod 'Spreedly'
    pod 'Alamofire'
    pod 'IGListKit'
    pod 'CardIO'
    pod 'SwiftKeychainWrapper'
    pod 'OneTimePassword', :git =>   'https://github.com/john/OneTimePassword.git', :branch => 'develop'
    pod 'SnapKit'
    pod 'DateToolsSwift'
    pod 'BetterSegmentedControl'
    pod 'SDWebImage'
    pod 'SwiftLocation'
    pod 'Nuke'
    pod 'Instabug'
    pod 'Mixpanel-swift'


    target 'App LibraryTests' do
        inherit! :search_paths
        # Pods for testing
    end

    target 'App' do
        project '../App/App'
        inherit! :complete

        use_frameworks!

        pod 'FacebookCore'
        pod 'FacebookLogin'

        target 'AppTests' do
            inherit! :search_paths
            # Pods for testing
        end
    end

    target 'App Business' do
         project '../App Business/App Business'
         inherit! :complete

         use_frameworks!

         target 'App BusinessTests' do
             inherit! :search_paths
             # Pods for testing
         end

         target 'App BusinessUITests' do
             inherit! :search_paths
             # Pods for testing
         end
     end

end

# The UI Test target I'm trying to run
target 'AppUITests' do
     inherit! :search_paths
     use_frameworks!
     # Pods for testing
     project '../App/App'
     pod 'Intercom'
     pod 'Spreedly'
     pod 'Alamofire'
     pod 'IGListKit'
     pod 'CardIO'
     pod 'SwiftKeychainWrapper'
     pod 'OneTimePassword', :git => 'https://github.com/john/OneTimePassword.git', :branch => 'develop'
     pod 'SnapKit'
     pod 'DateToolsSwift'
     pod 'BetterSegmentedControl'
     pod 'SDWebImage'
     pod 'SwiftLocation'
     pod 'Nuke'
     pod 'FacebookCore'
     pod 'FacebookLogin'
     pod 'Instabug'
     pod 'Mixpanel-swift'
end

workspace '../app-ios-client'

I have tried putting the UI test target inside the target app with !inherit:complete and !inherit:search_paths, moving it outside like in the code posted above. I have also cleaned the build folders, deleted derived data and restarted Xcode and I still have this problem. I have also tried adding import UIKit and import Alamofire and nothing has worked. Between all this possible fixes I have run pod deintegrate followed by pod install. I think the problem may be related to the podfile being inside my custom framework but honestly I have no idea. Any ideas? Thank you!


Solution

  • I fixed it by changing that target in my podfile to this:

    target 'AppUITests' do
        inherit! :search_paths
        use_frameworks!
        # Pods for testing
        project '../App/App'
    end