20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/cocoapods_plugin.rb', line 20
def self.modify_schemes_settings(xcproj, test_specs)
project_path = xcproj.path
test_targets = xcproj.targets.select { |target| test_specs.include?(target.name.to_s) }
Dir[File.join(project_path, 'xcuserdata', '**', 'xcschemes', '*.xcscheme')].select { |e|
!test_targets.select { |target|
File.basename(e, '.xcscheme').start_with?("#{target.name.to_s}-Unit")
}.empty?
}.each do |path|
scheme = File.basename(path, '.xcscheme')
puts "Check scheme: #{scheme}"
scheme_targets = test_targets.select { |e| scheme.include?(e.name.to_s) }
unless scheme_targets.empty?
puts "Test scheme: #{scheme} with targets: " + scheme_targets.map { |e| e.name.to_s }.join(",")
xcproj_scheme = Xcodeproj::XCScheme.new(file_path = path)
testAction = xcproj_scheme.test_action
testAction.code_coverage_enabled = true
testAction.coverage_specified_targets = true
scheme_targets.each { |e| testAction.add_coverage_target(e) }
File.delete(path)
xcproj_scheme.save_as(project_path, scheme)
else
File.delete(path)
end
end
end
|