bazel-ios / rules_ios

Bazel rules for building iOS applications and frameworks
Apache License 2.0
276 stars 84 forks source link

"failed to find TestImports-Unit-Tests.xctest in expected locations:" if `apple.experimental.tree_artifact_outputs` is set to `1` #854

Open thiagohmcruz opened 5 months ago

thiagohmcruz commented 5 months ago

Invoke xcodebuild

xcodebuild -project tests/ios/xcodeproj/Test-Imports-App-Project.xcodeproj -scheme TestImports-Unit-Tests -destination "id=SOME_VALID_SIM_ID" -PBXBuildsContinueAfterErrors=0 test


You'll hit this err:
```sh
Testing failed:
        failed to find TestImports-Unit-Tests.xctest in expected locations: bazel-bin//tests/ios/unit-test/test-imports-app/TestImports-Unit-Tests.xctest bazel-bin//tests/ios/unit-test/test-imports-app/TestImports-Unit-Tests.__internal__.__test_bundle_archive-root/TestImports-Unit-Tests.xctest bazel-bin//tests/ios/unit-test/test-imports-app/TestImports-Unit-Tests.runfiles/_main//tests/ios/unit-test/test-imports-app/TestImports-Unit-Tests.xctest bazel-bin//tests/ios/unit-test/test-imports-app/TestImports-Unit-Tests.runfiles/_main//tests/ios/unit-test/test-imports-app/TestImports-Unit-Tests.zip
        Testing cancelled because the build failed.

The issue doesn't happen if apple.experimental.tree_artifact_outputs is set to 0.

thiagohmcruz commented 5 months ago

The only two ways I was able to avoid this:

  1. Set transition_support.apple_rule_transition as an incoming edge transition in the legacy_xcodeproj.bzl => xcodeproj rule
  2. Set transition_support.apple_platform_split_transition as an outgoing edge transition in the same rule above for its deps attribute

Both "hacks" require the platform_type and minimum_os_version attributes to be set to something in the rule (rules_apple requirement) and I'm debating if this is even the right approach here. I doesn't make a lot of sense for the project to be opinionated on platform_type/minimum_os_version.

Given that this generator is getting more and more in "life support" mode due to most folks moving to rules_xcodeproj one might want to avoid setting apple.experimental.tree_artifact_outputs=1 when building from this generator as a workaround as I'm not convinced that its worth investing time in adjusting the rule to run well with the latest transitions-related changes that landed in rules_ios recently (e.g. 1, 2, 3).

We might want to simply close this once we deprecate the legacy generator.