运行测试时Xcode 11.6崩溃-库丢失

时间:2020-08-11 08:25:49

标签: swift xcode cocoapods

我正在尝试运行一些XCTest。我已经不太熟悉了。我导入了我的主模块来测试一些类。我必须打开xcworkspace,而不是xcodeproj,然后编译。

但是,我仍然遇到问题。我正在macOS上使用CocoaPods将Sparkle和AppCenter添加到该应用程序。它在主应用程序中可以正常工作,但是当我运行测试时,它崩溃并显示以下消息:

dyld: warning: could not load inserted library '/Users//Library/Developer/Xcode/DerivedData/.../Frameworks/libXCTestBundleInject.dylib' into hardened process because no suitable image found.

dyld: Library not loaded: @rpath/Sparkle.framework/Versions/A/Sparkle

我试图导入这些框架,但它们也不起作用。我在构建设置中做错了什么还是缺少了什么?

我还尝试将它们添加到Podfile中,但该方法也不起作用。

那是我的测试班:

@testable import MyApplication
import XCTest

class MoneyTest: XCTestCase {

    var moneyEUR1 : Money!

    override func setUpWithError() throws {
        // Put setup code here. This method is called before the invocation of each test method in the class.

        self.moneyEUR1 = Money(number: 1200, currency: "EUR")
    }

    override func tearDownWithError() throws {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
        
        self.moneyEUR1 = nil
    }

我的Podfile:

target 'MyApplication' do
  # Comment the next line if you don't want to use dynamic frameworks
  #use_frameworks!

  # Pods for MyApplication

  pod 'AppCenter'
  pod 'Sparkle'

  target 'MyApplication Tests' do
    inherit! :search_paths
    # Pods for testing
    # here I tried to add the pod aswell, which didn't work
    # it should actually inherit? shouldn't it?
  end
    
end

我不知道将Pods框架添加到测试目标的位置。

0 个答案:

没有答案