Xcode运行UITests崩溃,多种Podfile解决方案无效求助
运行Xcode UITests时崩溃,尝试多种方案未解决
在Xcode中运行UITests时遭遇崩溃,报错信息如图所示。已尝试以下多种解决方案,但问题仍未解决:
已尝试的操作
- 在Podfile中添加网上推荐的移除重复framework的代码:
def remove_duplicated_frameworks(app_pod_name, installer) test_targets = get_test_targets(app_pod_name, installer) puts "Detected test targets: #{test_targets}" puts "Removing duplicated frameworks from OTHER_LDFLAGS" targets = installer.aggregate_targets.select { |x| !test_targets.include?(x.name) } # Checks each pair of targets if they have common pods. Duplicates are removed from the first one's xcconfig. for i in 0..targets.size-1 do target = targets[i] remainingAppPodTargets = targets[i+1..targets.size-1].flat_map(&:pod_targets) target.xcconfigs.each do |config_name, config_file| # Removes all frameworks which exist in other pods remainingAppPodTargets .flat_map { |pod_target| get_framework_names(pod_target) } .each { |framework| config_file.frameworks.delete(framework) } # Saves updated xcconfig xcconfig_path = target.xcconfig_path(config_name) config_file.save_as(xcconfig_path) end end end def get_test_targets(app_pod_name, installer) main_target_name = app_pod_name.gsub("Pods-", "") installer.aggregate_targets .find { |x| x.name == app_pod_name } .user_project .targets .select { |x| x.test_target_type? } .flat_map { |x| ["Pods-#{x}", "Pods-#{main_target_name}-#{x}"] } .select { |x| installer.aggregate_targets.map(&:name).include?(x) } .uniq end def get_framework_names(pod_target) frameworkNames = pod_target.specs.flat_map do |spec| # We should take framework names from 'vendored_frameworks'. # If it's not defined, we use 'spec.name' instead. # # spec.name can be defined like Framework/Something - we take the first part # because that's what appears in OTHER_LDFLAGS. frameworkPaths = unless spec.attributes_hash['ios'].nil? then spec.attributes_hash['ios']['vendored_frameworks'] else spec.attributes_hash['vendored_frameworks'] end || [spec.name.split(/\//, 2).first] map_paths_to_filenames(frameworkPaths) end frameworkNames.uniq end def map_paths_to_filenames(paths) Array(paths).map(&:to_s).map do |filename| extension = File.extname filename File.basename filename, extension end end
- 替换为以下Podfile代码并执行
pod install,问题依旧:
sharedLibrary = installer.aggregate_targets.find { |aggregate_target| aggregate_target.name == 'Pods-[MY_FRAMEWORK_TARGET]' } installer.aggregate_targets.each do |aggregate_target| if aggregate_target.name == 'Pods-[MY_APP_TARGET]' aggregate_target.xcconfigs.each do |config_name, config_file| sharedLibraryPodTargets = sharedLibrary.pod_targets aggregate_target.pod_targets.select { |pod_target| sharedLibraryPodTargets.include?(pod_target) }.each do |pod_target| pod_target.specs.each do |spec| frameworkPaths = unless spec.attributes_hash['ios'].nil? then spec.attributes_hash['ios']['vendored_frameworks'] else spec.attributes_hash['vendored_frameworks'] end || Set.new frameworkNames = Array(frameworkPaths).map(&:to_s).map do |filename| extension = File.extname filename File.basename filename, extension end end frameworkNames.each do |name| if name != '[DUPLICATED_FRAMEWORK_1]' && name != '[DUPLICATED_FRAMEWORK_2]' raise("Script is trying to remove unwanted flags: #{name}. Check it out!") end puts "Removing #{name} from OTHER_LDFLAGS" config_file.frameworks.delete(name) end end end xcconfig_path = aggregate_target.xcconfig_path(config_name) config_file.save_as(xcconfig_path) end end
- 将
use_frameworks!设置为全局配置,仍无法解决问题。
目前崩溃问题持续,UITests无法正常运行,恳请提供帮助!
内容的提问来源于stack exchange,提问作者Mirella Candy
相关产品推荐
相关产品推荐

