I'm writing a post_install
script in my Podfile
in order to enable gathering of code coverage reports from my framework when I run the unit tests in the example project. Here's what I've got:
post_install do |installer|
pods_project = installer.pods_project
shared_data_dir = Xcodeproj::XCScheme.shared_data_dir(pods_project.path)
scheme_filename = "BonMot.xcscheme"
scheme = Xcodeproj::XCScheme.new File.join(shared_data_dir, scheme_filename)
test_action = scheme.test_action
test_action.code_coverage_enabled = true
scheme.test_action = test_action
puts "now scheme is #{scheme}"
scheme.save!
end
When I print out the scheme, I can confirm that code coverage gathering is enabled, and when I check the modification date of the file, it is updated to the current time, although that is easily explained by the fact that I'm running pod install
. The code coverage option is not being written back to the BonMot.xcscheme
file. Why not?