【问题标题】:Xcode 7 UI Testing with Cocoapods fails on device使用 Cocoapods 进行 Xcode 7 UI 测试在设备上失败
【发布时间】:2016-02-26 01:49:43
【问题描述】:

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

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 加载哪些框架并不重要。它会在每个框架上失败。

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

如果我使用模拟器,一切正常。

这是我的 pod 文件:

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

【问题讨论】:

  • 您找到解决方案了吗?

标签: ios xcode xctest xcode-ui-testing


【解决方案1】:

就我而言,我必须在我的一个 UI 测试中导入 UIKit 和 CoreData。然后确保进行完全干净的构建CMD-Shift-k)。

import XCTest
import UIKit
import CoreData

class MyUITests: XCTestCase {

【讨论】:

  • 这解决了问题吗?我试过了,但仍然有同样的问题
  • @mtet88,是的,这些步骤确实解决了我的问题。可能您正在使用需要添加到导入列表中的其他框架?此外,如上所述,进行完全干净的构建也是关键。
【解决方案2】:

仅供参考,对我有用的解决方案只是在测试目标中手动设置您的主机应用程序

【讨论】:

    【解决方案3】:

    正在改变,

    目标 -> 构建设置 -> ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES - > Value(Boolean) to $(inherited).

    然后构建成功。

    • Xcode 11.3 (11C29)
    • CocoaPods 1.8.4

    【讨论】:

      猜你喜欢
      • 2016-03-20
      • 2015-11-04
      • 1970-01-01
      • 2016-11-08
      • 1970-01-01
      • 2016-01-29
      • 2017-02-19
      • 2016-02-29
      • 2015-12-10
      相关资源
      最近更新 更多