我愿意添加单元和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/libSwitSwiftOnoneSupport.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结荚,并且只让它在我的应用程序和单元测试目标中运行时,它工作得很好。
发布于 2018-10-11 16:57:32
查看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 发布于 2019-01-04 07:45:43
尝试添加inherit!:search_paths
以及改变ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES在post_install中的应用
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发布于 2019-02-04 06:36:10
我也面临着这个问题,其他任何建议都没有奏效。
过了一段时间,我发现在代码中的任何地方使用print()都会强制加载libswiftSwiftOnoneSupport.dylib,这个问题就会消失。
我使用的是Xcode 10.1,Swift 4.2,给我这个问题的吊舱是灵活的。
希望这能有所帮助!
https://stackoverflow.com/questions/52666055
复制相似问题