diff --git a/lib/slather/project.rb b/lib/slather/project.rb index 6fa3f40f..37ce57c8 100755 --- a/lib/slather/project.rb +++ b/lib/slather/project.rb @@ -158,14 +158,29 @@ def profdata_coverage_dir raise StandardError, "The specified build directory (#{self.build_directory}) does not exist" unless File.exists?(self.build_directory) dir = nil if self.scheme - dir = Dir[File.join("#{build_directory}","/**/CodeCoverage/#{self.scheme}")].first + dir = Dir[File.join(build_directory,"/**/CodeCoverage/#{self.scheme}")].first else - dir = Dir[File.join("#{build_directory}","/**/#{first_product_name}")].first + dir = Dir[File.join(build_directory,"/**/#{first_product_name}")].first end if dir == nil # Xcode 7.3 moved the location of Coverage.profdata - dir = Dir[File.join("#{build_directory}","/**/CodeCoverage")].first + dir = Dir[File.join(build_directory,"/**/CodeCoverage")].first + end + + if dir == nil && Slather.xcode_version[0] >= 9 + # Xcode 9 moved the location of Coverage.profdata + coverage_files = Dir[File.join(build_directory, "/**/ProfileData/*/Coverage.profdata")] + + if coverage_files.count == 0 + # Look up one directory + # The ProfileData directory is next to Intermediates.noindex (in previous versions of Xcode the coverage was inside Intermediates) + coverage_files = Dir[File.join(build_directory, "../**/ProfileData/*/Coverage.profdata")] + end + + if coverage_files != nil + dir = Pathname.new(coverage_files.first).parent() + end end raise StandardError, "No coverage directory found." unless dir != nil @@ -406,9 +421,15 @@ def find_binary_files end search_list = binary_basename || find_buildable_names(xcscheme) + search_dir = profdata_coverage_dir + + if Slather.xcode_version[0] >= 9 + # Go from the directory containing Coverage.profdata back to the directory containing Products (back out of ProfileData/UUID-dir) + search_dir = File.join(search_dir, '../..') + end search_list.each do |search_for| - found_product = Dir["#{profdata_coverage_dir}/Products/#{configuration}*/#{search_for}*"].sort { |x, y| + found_product = Dir["#{search_dir}/Products/#{configuration}*/#{search_for}*"].sort { |x, y| # Sort the matches without the file extension to ensure better matches when there are multiple candidates # For example, if the binary_basename is Test then we want Test.app to be matched before Test Helper.app File.basename(x, File.extname(x)) <=> File.basename(y, File.extname(y))