在单元测试开始运行期间不会加载链接的框架

时间:2019-06-25 09:16:00

标签: ios unit-testing cocoapods webrtc

我有一个框架项目,该项目依赖于两个链接的框架和几个吊舱(cocoapods框架)。项目正在编译并且构建良好,但是由于在运行时启动期间单元测试停止并显示在控制台中,因此我无法运行单元测试:

2019-06-25 13:22:36.587119+0500 xctest[39466:11001754] The bundle “UnitTests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2019-06-25 13:22:36.587399+0500 xctest[39466:11001754] (dlopen_preflight(.../Library/Developer/Xcode/DerivedData/Foo-cyvwfwgmlheydhcngjadgtqrmqfm/Build/Products/Debug-iphonesimulator/UnitTests.xctest/UnitTests): Library not loaded: @rpath/WebRTC.framework/WebRTC
  Referenced from: .../Library/Developer/Xcode/DerivedData/Foo-cyvwfwgmlheydhcngjadgtqrmqfm/Build/Products/Debug-iphonesimulator/Foo.framework/Foo
  Reason: image not found)
Program ended with exit code: 82

如果我用自己的双手将WebRTC.framework放入“ ... / Library / Developer / Xcode / DerivedData / Foo-cyvwfwgmlheydhcngjadgtqrmqfm / Build / Products / Debug-iphonesimulator / UnitTests.xctest / Frameworks”预期的。

这是我的Podfile:

...
source 'https://github.com/cocoapods/specs.git'

platform :ios, '9.0'
inhibit_all_warnings!
use_frameworks!

def import_common_pods
  pod 'SnapKit', '~> 4.2.0'
  pod 'SwiftGen', '~> 6.0'
  ...
end

target :Foo do
  import_common_pods
end

target :UnitTests do
  import_common_pods
  pod 'Quick', '~> 1.3.2'
  pod 'Nimble', '~> 7.3.1'
end

post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings['SWIFT_VERSION'] = '5.0'
  end
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '5.0'
    end
  end
end

在构建项目期间,我需要自动将WebRTC.framework放入“ ... / Library / Developer / Xcode / DerivedData / Foo-cyvwfwgmlheydhcngjadgtqrmqfm / Build / Products / Debug-iphonesimulator / UnitTests.xctest / Frameworks”。我该怎么办?

0 个答案:

没有答案