Xcode 7 UI Testing with Cocoapods fails on device

梦想的初衷 提交于 2019-12-22 04:29:18

问题


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

回答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 {



回答2:


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




回答3:


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


来源:https://stackoverflow.com/questions/33879799/xcode-7-ui-testing-with-cocoapods-fails-on-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!