【问题标题】:How can I run XCTest in my project there was a runtime error occur如何在我的项目中运行 XCTest,出现运行时错误
【发布时间】:2019-02-02 02:53:59
【问题描述】:

我创建了一个 Xcode 框架项目,然后我使用 CocoaPods 导入另一个模块。然后我想写一个单元测试。

但是当单元测试运行时,出现了运行时错误

2019-02-02 10:20:39.157536+0800 xctest[90385:6327514] The bundle “XXX” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2019-02-02 10:20:39.157855+0800 xctest[90385:6327514] (dlopen_preflight(/Users/XXX/Library/Developer/Xcode/DerivedData/XXX-dfsjsywxidmqgmaudrhgrhgniihc/Build/Products/Debug-iphonesimulator/XXX.xctest/XXXTests): Library not loaded: @rpath/XXX1.framework/XXX1
  Referenced from: /Users/XXX/Library/Developer/Xcode/DerivedData/XXX-dfsjsywxidmqgmaudrhgrhgniihc/Build/Products/Debug-iphonesimulator/XXX.framework/XXX
  Reason: image not found)
Program ended with exit code: 82

如何解决这个问题。

【问题讨论】:

    标签: ios swift xcode frameworks


    【解决方案1】:

    在您的 Podfile 中,确保您的模块也可用于您的单元测试目标。

    这是一个示例,一些 pod 继承自主要目标,其他仅可用于测试目的。

    platform :ios, '8.0'
    use_frameworks!
    
    target 'MyApp' do
    
        pod 'AFNetworking', '~> 2.6'
        pod 'ORStackView', '~> 3.0'
        pod 'SwiftyJSON', '~> 2.3'
    
        target 'MyAppTests' do
            inherit! :search_paths
            pod 'Quick'
        end
    end
    

    【讨论】:

    • 我按步骤 1. 添加测试目标 2. 运行 pod install 3. 清理我的项目 4. 开始测试 但错误仍然存​​在
    • 另一个想法,确保您的FRAMEWORK_SEARCH_PATHS 具有正确的设置并包括$(inherited) - github.com/CocoaPods/CocoaPods/issues/…
    • ohhhhhhhh,这个没救了,错误还是存在,要不要在github上发issue?
    猜你喜欢
    • 2016-05-16
    • 2021-02-22
    • 2021-06-19
    • 2020-11-16
    • 2018-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多