本文介绍了使用 Cocoapods 的 Xcode 7 UI 测试在设备上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在我的设备上运行 UI 测试时出现错误:

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

XCTRunner[1476:104021] 无法加载包AppUITests"因为它已损坏或缺少必要的资源.尝试重新安装捆绑.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):库未加载:@rpath/UIColor_Hex_Swift.framework/UIColor_Hex_Swift引用自:/var/mobile/Containers/Bundle/Application/FAC2EFB2-92C6-4668-96A7-C77CC5C4AE87/AppUITests-Runner.app/PlugIns/AppUITests.xctest/AppUITests原因:图片未找到)

在这种情况下,它是UIColor_Hex_Swift.framework",它在我的 podfile 中.但是我从 cocoapods 加载哪些框架并不重要.它会在每个框架上失败.

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.

我尝试过更改 pod 文件、清理、删除派生数据、重新安装 pod 和更改签名.不,我没有想法.

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.

这是我的 pod 文件:

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

推荐答案

就我而言,我不得不在我的一个 UI 测试中导入 UIKit 和 CoreData.然后确保进行完全干净的构建(--).

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 (--).

import XCTest
import UIKit
import CoreData

class MyUITests: XCTestCase {

这篇关于使用 Cocoapods 的 Xcode 7 UI 测试在设备上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 21:14