1

我正在尝试按照以下步骤安装框架,使用 EarlGrey 2.0 将 UI 测试添加到我的项目中:https ://www.youtube.com/watch?v= KQaA11qVQn0(使用 Cocoapods)。它构建成功,但是当我尝试运行测试时,出现此错误:

2020-11-27 14:18:16.076586+0700 X-UITests-Runner[75526:5465621] The bundle X-UITests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2020-11-27 14:18:16.076704+0700 X-UITests-Runner[75526:5465621] (dlopen_preflight(/X-blqsydhdzeecqndvwzwsshajcwdm/Build/Products/Debug-iphonesimulator/X-UITests-Runner.app/PlugIns/X-UITests.xctest/X-UITests): Library not loaded: @rpath/Alamofire.framework/Alamofire
  Referenced from: /X-blqsydhdzeecqndvwzwsshajcwdm/Build/Products/Debug-iphonesimulator/X-UITests-Runner.app/PlugIns/X-UITests.xctest/X-UITests
  Reason: image not found)

我的 podfile 上有这个:

use_frameworks!

def shared_pods
  pod 'Alamofire'
  pod 'Firebase'
  pod 'Firebase/Analytics'
  pod 'Firebase/RemoteConfig'
  pod 'Firebase/Crashlytics'
  pod 'Firebase/Messaging'
  pod 'Firebase/Auth'
  pod 'Firebase/Database'
  pod 'Introspect'
  pod 'ReachabilitySwift'
  pod 'RealmSwift'
  pod 'SDWebImageSwiftUI'
  pod 'SwiftKeychainWrapper'
  pod 'Zip'
end

target 'X' do
  shared_pods
  pod 'EarlGreyApp'
end

target 'X-UITests' do
  inherit! :search_paths
  pod 'EarlGreyTest'
  pod 'eDistantObject', '0.9.0'
end

我试图取消选中该Find Implicit Dependencies计划,但仍然出现错误。有什么帮助吗?谢谢。

4

2 回答 2

0

尝试使用 use_frameworks!在目标旁边,

    def shared_pods
      pod 'Alamofire'
      pod 'Firebase'
      pod 'Firebase/Analytics'
      pod 'Firebase/RemoteConfig'
      pod 'Firebase/Crashlytics'
      pod 'Firebase/Messaging'
      pod 'Firebase/Auth'
      pod 'Firebase/Database'
      pod 'Introspect'
      pod 'ReachabilitySwift'
      pod 'RealmSwift'
      pod 'SDWebImageSwiftUI'
      pod 'SwiftKeychainWrapper'
      pod 'Zip'
    end

    target 'X' do
      use_frameworks!
      shared_pods
      pod 'EarlGreyApp'
    end

    target 'X-UITests' do
      use_frameworks!
      inherit! :search_paths
      pod 'EarlGreyTest'
      pod 'eDistantObject', '0.9.0'
    end
于 2020-11-29T13:48:27.583 回答
0

一般来说,这种错误表示您尝试测试的某些类依赖于 Alamofire pod。因此,您还必须将 Alamofire 添加到您的测试目标中

target 'X-UITests' do
    ...
    pod 'Alamofire'
    ...
end
于 2020-12-04T10:03:02.453 回答