MobileNativeFoundation / rules_xcodeproj

Bazel rules for generating Xcode projects.
MIT License
521 stars 83 forks source link

Bug: "Multiple commands produce" error for test targets with same name #3000

Closed CognitiveDisson closed 5 months ago

CognitiveDisson commented 5 months ago

Description

If a scheme contains two test targets with the same name, the build will fail, with the following error:

error: Multiple commands produce '<Touch /Users/vadims/DD/Integration-fchgxtvzxxtuejfflddfdmeyscna/Build/Products/Debug-iphonesimulator/bazel-out/ios_sim_arm64-dbg-ios-sim_arm64-min15.0-applebin_ios-ST-a89b5310e066/bin/iOSApp/Source/iOSApp.app/PlugIns/iOSAppObjCUnitTests.xctest>'

We encountered this problem with other types of output files, such as link.params and c.compile.params.

Reproduction steps

After making some modifications, I was able to reproduce this issue on an example project. Here is the branch. Diff.

  1. Checkout this branch
  2. Generate a project - bazelisk run --config=cache //:xcodeproj-incremental-bazel-sim_arm64
  3. Open it ( xed Integration.xcodeproj )
  4. Select the iOSAppUnitTests_Scheme scheme
  5. Run tests - ⌘U
  6. See the build error

The key change that led to this issue was a test target with the same name. Changing the target name should resolve the problem. It assume that rules_xcodeproj uses the target name to specify the output file location for the "Create Link Dependencies" step, leading to a collision.

Also, this issue can only be reproduced for the Objective-C test targets, as the Xcode target for swift tests does not include this step.

Expected behavior

There's no error even if two targets have the same name.

rules_xcodeproj version

11e698b0b987def9db74f24a9473a3b7fc6c0594

Xcode version

15.1

Bazel version

7.1.0

rules_apple version

No response

rules_swift version

No response

Additional information

No response

brentleyjones commented 5 months ago
error: Multiple commands produce '<Touch /Users/vadims/DD/Integration-fchgxtvzxxtuejfflddfdmeyscna/Build/Products/Debug-iphonesimulator/bazel-out/ios_sim_arm64-dbg-ios-sim_arm64-min15.0-applebin_ios-ST-a89b5310e066/bin/iOSApp/Source/iOSApp.app/PlugIns/iOSAppObjCUnitTests.xctest>'

This error is expected. Both tests produce a bundle with the same name. They both can't be put into the test host. A normal Xcode project wouldn't support this either.

We encountered this problem with other types of output files, such as link.params and c.compile.params.

I have a fix for this part coming though.