我试图在我的应用程序中运行UI测试,但是一旦模拟器启动,我就会得到:
包“AppUITests”无法加载,因为它已损坏或缺少必要的资源。试着重新安装包。
2018-10-05 11:04:59.772078-0500应用程序-Runner53273:1645870
我的UITest是Xcode 10创建的模板,我使用Cocoapods 1.5.3和SWIFT4.2
我的项目结构:
我的文件看起来是这样的:
platform :ios, '10.0'
inhibit_all_warnings!
use_frameworks!
target 'App Library' do
use_frameworks!
pod 'Intercom'
pod 'Spreedly'
pod 'Alamofire'
pod 'IGListKit'
pod 'CardIO'
pod 'SwiftKeychainWrapper'
pod 'OneTimePassword', :git => 'https://github.com/john/OneTimePassword.git', :branch => 'develop'
pod 'SnapKit'
pod 'DateToolsSwift'
pod 'BetterSegmentedControl'
pod 'SDWebImage'
pod 'SwiftLocation'
pod 'Nuke'
pod 'Instabug'
pod 'Mixpanel-swift'
target 'App LibraryTests' do
inherit! :search_paths
# Pods for testing
end
target 'App' do
project '../App/App'
inherit! :complete
use_frameworks!
pod 'FacebookCore'
pod 'FacebookLogin'
target 'AppTests' do
inherit! :search_paths
# Pods for testing
end
end
target 'App Business' do
project '../App Business/App Business'
inherit! :complete
use_frameworks!
target 'App BusinessTests' do
inherit! :search_paths
# Pods for testing
end
target 'App BusinessUITests' do
inherit! :search_paths
# Pods for testing
end
end
end
# The UI Test target I'm trying to run
target 'AppUITests' do
inherit! :search_paths
use_frameworks!
# Pods for testing
project '../App/App'
pod 'Intercom'
pod 'Spreedly'
pod 'Alamofire'
pod 'IGListKit'
pod 'CardIO'
pod 'SwiftKeychainWrapper'
pod 'OneTimePassword', :git => 'https://github.com/john/OneTimePassword.git', :branch => 'develop'
pod 'SnapKit'
pod 'DateToolsSwift'
pod 'BetterSegmentedControl'
pod 'SDWebImage'
pod 'SwiftLocation'
pod 'Nuke'
pod 'FacebookCore'
pod 'FacebookLogin'
pod 'Instabug'
pod 'Mixpanel-swift'
end
workspace '../app-ios-client'我尝试过用!inherit:complete和!inherit:search_paths将UI测试目标放在目标应用程序中,并将其移到外面,就像上面发布的代码一样。我还清理了构建文件夹,删除了派生数据并重新启动了Xcode,我仍然存在这个问题。我也尝试过添加import UIKit和import Alamofire,但是没有什么效果。在所有这些可能的修复之间,我运行了pod deintegrate和pod install。我认为问题可能与podfile在我的自定义框架内有关,但老实说,我不知道。有什么想法吗?谢谢!
发布于 2018-10-05 17:21:48
我通过将podfile中的目标更改为:
target 'AppUITests' do
inherit! :search_paths
use_frameworks!
# Pods for testing
project '../App/App'
end发布于 2019-12-17 00:48:24
我的修补程序与https://stackoverflow.com/a/54034832/883413类似,只是我没有费心使用post_install部分。
以前,我的podfile结构类似于问题中的结构:
platform :ios, '10.0'
target 'AppName' do
use_frameworks!
pod 'PodName'
target 'AppNameTests' do
inherit! :search_paths
end
target 'AppNameUITests' do
inherit! :search_paths
end
end改为(更新的?)这样的结构解决了这个问题:
platform :ios, '10.0'
use_frameworks!
def all_pods
pod 'PodName'
end
target 'AppName' do
all_pods
end
target 'AppNameTests' do
inherit! :search_paths
all_pods
end
target 'AppNameUITests' do
inherit! :search_paths
all_pods
end发布于 2019-01-04 07:40:09
除了添加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
endhttps://stackoverflow.com/questions/52669835
复制相似问题