Ios 束“;MyProjectUITests”;不能’;无法加载,因为它已损坏或缺少必要的资源。尝试重新安装捆绑包
我愿意在我的应用程序中添加单元和UI测试 我首先成功地配置了单元测试,我尝试对UI测试进行同样的配置。这是我的pod文件,在添加了新的UI测试包目标之后:Ios 束“;MyProjectUITests”;不能’;无法加载,因为它已损坏或缺少必要的资源。尝试重新安装捆绑包,ios,xcode-ui-testing,Ios,Xcode Ui Testing,我愿意在我的应用程序中添加单元和UI测试 我首先成功地配置了单元测试,我尝试对UI测试进行同样的配置。这是我的pod文件,在添加了新的UI测试包目标之后: platform :ios, '8.0' use_frameworks! inhibit_all_warnings! def shared_pods pod 'Bolts' pod 'Branch' pod 'FBSDKCoreKit' pod 'FBSDKLoginKit' pod 'FBSDKShareKit' pod 'GoogleA
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_飞行前(/var/containers/Bundle/Application/5A1FE39F-E675-4A47-9BF4-FBCDB96F5821/MyProjectUITests Runner.app/PlugIns/MyProjectUITests.xTest/MyProjectUITests):库未加载:@rpath/libswitswitswitsWiftOneSupport.dylib
引用自:/private/var/containers/Bundle/Application/5A1FE39F-E675-4A47-9BF4-FBCDB96F5821/MyProjectUITests-Runner.app/PlugIns/MyProjectUITests.xTest/Frameworks/Toast\u Swift.framework/Toast\u Swift
原因:未找到图像)
怎么了?谢谢你的帮助
编辑:关于信息,当我从我的UI测试目标中删除该Toast\u swift
pod,并仅将其放在我的应用程序和单元测试目标中时,它可以正常工作。在cocoapods github问题跟踪器上查看
我仍然有点困惑为什么这会成为一个问题,但是使用此脚本将始终嵌入\u SWIFT\u标准\u库设置为是解决了这个问题
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
尝试添加继承!:搜索路径
还可以在安装后更改“始终嵌入”“快速”“标准”库
我也面临着这个问题,其他建议都不起作用
过了一会儿,我发现在代码中的任何地方使用print()
都会以某种方式强制加载libswitswittononesupport.dylib,问题就会消失
我使用的是Xcode 10.1、Swift 4.2,而给我这个问题的pod非常灵活
希望这有帮助 CMD+Shift+KI我已经尝试过了,但没有成功。(见我帖子中的编辑)你使用的是xCode 10吗?@JonVogel是的,确实是10.0版。我也读了这篇文章并尝试了这一点,但我一直收到这个错误。它只发生在UI测试中,甚至在单元测试中也不会发生。因此,我最终将框架代码粘贴到我的UI测试目标中,但这确实不方便。。
use_frameworks!
def shared_pods
pod 'SomePod'
end
target 'App_name' do
shared_pods
end
target 'App_nameTests' do
inherit! :search_paths
shared_pods
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'YES'
end
end
end