Xcode 7 UI Testing with Cocoapods fails on device
Asked Answered
C

3

8

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
Catania answered 23/11, 2015 at 20:12 Comment(1)
Did you find a solution?Machination
P
1

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 {
Pelagias answered 17/1, 2016 at 21:8 Comment(2)
Did this solve the problem? I tried this but still having the same issueFlattop
@mtet88, Yes these steps did solve my issues. Possibly you're using other frameworks that you need to add to the import list? Also, it's key to do a completely clean build as noted above.Pelagias
E
0

Just for reference, the solution that have worked for me is just sets manually your Host Application in the test target

enter image description here

Effortless answered 17/10, 2016 at 15:31 Comment(0)
F
0

was changing,

Target - > building settings - > ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES - > Value(Boolean) to $(inherited).

then got the build success.

  • Xcode 11.3 (11C29)
  • CocoaPods 1.8.4
Faery answered 12/12, 2019 at 14:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.