bazel-ios/rules_ios

Support for bazel coverage command with dynamic apple_framework targets

mccorkill1 opened this issue · 1 comments

When running bazel coverage against an ios_unit_test target that depends on an apple_framework target with link_dynamic = 1, the coverage report generated does not include the files from the apple_framework target. If link_dynamic = 0, those files are included in the coverage report.

See https://github.com/mccorkill1/CoverageExample for an example with instructions in the readme to recreate the problem.

The solution to this is to include the apple_framework target dependency to the frameworks attribute of the ios_unit_test. rules_apple decides which binaries to pass as arguments to xcrun llvm. Without adding it to the frameworks attribute, only the test binary is passed as an argument, so it works for statically linked framework but not dynamically linked. Adding the framework to the frameworks attribute of the ios_unit_test gets the framework added as a binary argument to xcrun llvm in addition to the unit tests which results in coverage on the framework when linked dynamically.