SPM dependency symbols duplicated in test target
I have a project that uses SPM and CocoaPods. Incidentally, pod install fails unless I force link: true for any SPM dependencies for my targets. So I have a static lib target with an SPM dependency with link: true, and a test target (with no test host) that exercises that static lib target. The lib target builds fine, but the test target fails due to all the SPM dependency's symbols being duplicated. There is no visible, direct linkage between the test target and the SPM dependency, other than through the static lib.
Removing link: true avoids the symbol duplication but as stated, I cannot remove it or pod install will subsequently fail.
Attached is a sample project demonstrating the setup.
Seems similar to https://github.com/yonaskolb/XcodeGen/issues/748 but since this involves test targets and that was an app target, this seemed different.
spm-unit-test-duplicate-symbol-example-xcodegen.zip
The xcodegen spec should read:
name: spm-unit-test-duplicate-symbol-example-xcodegen
packages:
RegularExpressionDecoder:
url: https://github.com/Flight-School/RegularExpressionDecoder
from: 0.1.0
schemes:
lib:
build:
targets:
lib: all
tests:
build:
targets:
tests: test
test:
targets: [tests]
targets:
lib:
type: library.static
sources:
- path: lib
platform: macOS
dependencies:
- package: RegularExpressionDecoder
link: true
deploymentTarget: 10.15
scheme:
testTargets:
- tests
tests:
type: bundle.unit-test
platform: macOS
deploymentTarget: 10.15
sources:
- path: tests
dependencies:
- target: lib