MobileNativeFoundation / rules_xcodeproj

Bazel rules for generating Xcode projects.
MIT License
528 stars 86 forks source link

Bug: The generation project encountered a duplicate target #2210

Closed Kila2 closed 8 months ago

Kila2 commented 1 year ago

Description

The generation project encountered a duplicate target, which corresponds to different configurations. Only //command_line_option: apple_split_cpu is different. I hope to optimize this duplicate target to avoid repeated compilation.

here is a deps graph example.

macos_command_line_applicationA
|-swift_libraryB
  |-swift_libraryA
macos_applicationA
|-swift_libraryC
  |-swift_libraryA

these target are set minimum_os_version to 11.0

I'm try custom rules_apple remove code about apple_split_cpu then generate project isn't contain duplicate target.

Reproduction steps

See the Description

Expected behavior

generate project don't contain duplicate target

rules_xcodeproj version

1.5.1

Xcode version

14.3

Bazel version

6.2.0

rules_apple version

No response

rules_swift version

No response

Additional information

RT

thiagohmcruz commented 1 year ago

If you could share a minimal repro it would be great 🙏

brentleyjones commented 1 year ago

This is expected, if your library has a different configuration: https://github.com/MobileNativeFoundation/rules_xcodeproj/blob/c59ed2a0d336a9331ca0323b7959a7c27be03e32/docs/faq.md#why-are-there-multiple-versions-of-some-of-my-targets

Since Bazel is going to compile it two different ways, we will as well. You'll need to find a way to make them have the same configuration (modifying the rules, or creating a wrapper rule that transitions them the same, etc.) if you don't want rules_xcodeproj or Bazel to compile a target twice.

Kila2 commented 1 year ago

If you could share a minimal repro it would be great 🙏

I was make minimal repo at https://github.com/Kila2/rules_xcodeproj/tree/issues/2210/examples/integration

cd /path/to/integration
$bazel run //:xcodeproj

use bazel config to get d9fd065 and 4a69d99 configuration

$bazel cquery "deps(//macOSApp/LibB:LibB)"
//macOSApp/LibB:LibB (d9fd065)
//macOSApp/LibB:LibB (4a69d99)
//macOSApp/LibB:LibB (c80b949)