Skip to content

Commit

Permalink
Merge pull request #339 from ksuther/xcode9
Browse files Browse the repository at this point in the history
Initial Xcode 9 support
  • Loading branch information
ksuther authored Sep 19, 2017
2 parents f478561 + 8f6c451 commit caea338
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions lib/slather/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit caea338

Please sign in to comment.