Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 7 UI Testing with Cocoapods fails on device

When trying to run my UI Tests on my device I get the error:

XCTRunner[1476:104021] The bundle “AppUITests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle. 2015-11-23 20:58:53.903 XCTRunner[1476:104021] (dlopen_preflight(/var/mobile/Containers/Bundle/Application/FAC2EFB2-92C6-4668-96A7-C77CC5C4AE87/AppUITests-Runner.app/PlugIns/AppUITests.xctest/TrueMostUITests): Library not loaded: @rpath/UIColor_Hex_Swift.framework/UIColor_Hex_Swift Referenced from: /var/mobile/Containers/Bundle/Application/FAC2EFB2-92C6-4668-96A7-C77CC5C4AE87/AppUITests-Runner.app/PlugIns/AppUITests.xctest/AppUITests Reason: image not found)

In this case it's "UIColor_Hex_Swift.framework", which is in my podfile. But it really doesn't matter which frameworks I load from cocoapods. It will fail on every framework.

I've tried changing pod file, cleaning, deleting derived data, re-installing pods and changing the signing. No I'm out of ideas.

Everything works fine if I'm using the simulator.

Here is my pod file:

platform :ios, '9.0'
workspace './AppWorkspace'
use_frameworks!
inhibit_all_warnings!
link_with 'App', 'AppTests', 'AppUITests'

target 'App', :exclusive => false do
    pod 'SwiftyJSON', '~> 2.3.0'
    pod 'MQTTKit', :git => 'https://github.com/mobile-web-messaging/MQTTKit.git'
    pod 'PromiseKit', '~> 3.0.0'
    pod 'UIColor_Hex_Swift',:git => 'https://github.com/yeahdongcn/UIColor-Hex-Swift.git', :branch => 'Swift-2.0'
    pod 'OHHTTPStubs', '~> 4.3.0'
    pod 'Alamofire', '~> 3.1.0'
end

def testing_pods()
#    pod 'SwiftyJSON', '~> 2.3.0'
#    pod 'MQTTKit', :git => 'https://github.com/mobile-web-messaging/MQTTKit.git'
#    pod 'PromiseKit', '~> 3.0.0'
    pod 'UIColor_Hex_Swift',:git => 'https://github.com/yeahdongcn/UIColor-Hex-Swift.git', :branch => 'Swift-2.0'
#    pod 'OHHTTPStubs', '~> 4.3.0'
#    pod 'Alamofire', '~> 3.1.0'
end


target 'AppTests', :exclusive => false do
    testing_pods
end

target 'AppUITests', :exclusive => false do
    testing_pods
end
like image 476
Mikael Avatar asked Nov 23 '15 20:11

Mikael


1 Answers

In my case I had to import UIKit and CoreData in one of my UI Tests. Then make sure to do a completely clean build (CMD-Shift-k).

import XCTest
import UIKit
import CoreData

class MyUITests: XCTestCase {
like image 200
David Hunt Avatar answered Nov 10 '22 00:11

David Hunt