ios - 无法加载捆绑包“MyProjectUITests”,因为它已损坏或缺少必要的资源。尝试重新安装捆绑包
问题描述
我愿意为我的应用程序添加单元和 UI 测试。
我首先成功地配置了单元测试,我尝试对 UI 测试做同样的事情。这是我的 Podfile,在添加了一个新的 UI 测试包目标之后:
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
但是,当我尝试运行自动创建的MyProjectUITests
测试用例时,它只包含基本设置,甚至没有@testable import MyProject
:
import XCTest
class MyProjectUITests: XCTestCase {
override func setUp() {
continueAfterFailure = false
XCUIApplication().launch()
}
}
我收到此错误:
运行测试...无法加载捆绑包“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
原因:图片未找到)
怎么了?谢谢你的帮助。
编辑:关于信息,当我从我的 UI 测试目标中删除该Toast_swift
pod 并让它只在我的应用程序和单元测试目标中时,它工作正常。
解决方案
在 cocoapods github 问题跟踪器上查看此问题。
我仍然有点困惑为什么这会成为一个问题,但是设置ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES
为YES
使用这个脚本为我解决了这个问题。
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
推荐阅读
- javascript - 验证表单 ng-click 功能不起作用后加载页面
- node.js - 授权中间件功能
- kubernetes - Kubernetes kubectl 不使用 prune 选项修剪资源
- javascript - 使用 Mongoose for Node.js 将 JSON 推送到 Mongo 文档的子数组中
- android - 物体检测和计算相机和物体之间的距离
- javascript - 在 array.forEach 函数语句中使用 if 语句来选择对象数组中的子对象
- r - 按组在多个列上执行多个函数,并创建信息丰富的列名
- javascript - 我想通过jq获取ng-show的值,但不是我预期的结果
- gnuplot - gnuplot 的问题 - 时间戳数据映射到 xrange
- python-2.7 - 使用 witdraw() 隐藏弹出框会导致窗口大小不合适