无法加载捆绑包“ MyProjectUITests”,因为它已损坏或缺少必要的资源。尝试重新安装捆绑包

Rob*_*Rob 2 ios xcode-ui-testing

我愿意在我的应用程序中添加单元和UI测试。

我首先成功配置了单元测试,然后尝试对UI测试进行同样的操作。这是我的Podfile,添加了新的UI Testing Bundle目标后:

platform :ios, '8.0'
use_frameworks!
inhibit_all_warnings!

def shared_pods
pod 'Bolts'
pod 'Branch'
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
pod 'FBSDKShareKit'
pod 'GoogleAnalytics'
pod 'GooglePlaces'
pod 'Parse'
pod 'Toast-Swift'
end

target 'MyTarget' do
shared_pods
end

target 'MyTargetUITests' do
shared_pods
end

target 'MyTargetUnitTests' do
shared_pods
end
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试运行自动创建的MyProjectUITests测试用例时,它仅包含基本设置,甚至没有@testable import MyProject

import XCTest

class MyProjectUITests: XCTestCase {

    override func setUp() {
        continueAfterFailure = false
        XCUIApplication().launch()
    }
}
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

正在运行测试...无法加载捆绑包“ MyProjectUITests”,因为它已损坏或缺少必要的资源。尝试重新安装捆绑软件。

(dlopen_preflight(/var/containers/Bundle/Application/5A1FE39F-E675-4A47-9BF4-FBCDB96F5821/MyProjectUITests-Runner.app/PlugIns/MyProjectUITests.xctest/MyProjectUITests):库未加载:@ rpath / libswiftSwiftOnoneSupport.dylib

引用自:/private/var/containers/Bundle/Application/5A1FE39F-E675-4A47-9BF4-FBCDB96F5821/MyProjectUITests-Runner.app/PlugIns/MyProjectUITests.xctest/Frameworks/Toast_Swift.framework/Toast_Swift

原因:找不到图片)

怎么了?谢谢你的帮助。

编辑:作为信息,当我Toast_swift从UI测试目标中删除该pod并仅在我的应用程序和单元测试目标中使用它时,它工作正常。

Jon*_*gel 6

在cocoapods github问题跟踪器上查看此问题

我还是有点困惑,为什么这成了一个问题,但设置ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIESYES使用这个脚本来修正这个问题对我来说。

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            # This works around a unit test issue introduced in Xcode 10.
            # We only apply it to the Debug configuration to avoid bloating the app size
            if config.name == "Debug" && defined?(target.product_type) && target.product_type == "com.apple.product-type.framework"
                config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = "YES"
            end
        end
    end
end 
Run Code Online (Sandbox Code Playgroud)