yonaskolb / yonaskolb/XcodeGen

SPM dependency symbols duplicated in test target

Open
#1,162 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
8.8k
Forks
908
Avg merge
17d 14h
Merged PRs (30d)
2

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the attached sample project and the provided XcodeGen YAML spec, then inspect the generated project and dependency settings for the static lib and its test target. Reproduce the test build with link: true; done means pod install still succeeds and the test target no longer reports duplicate SPM dependency symbols.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift, yaml
Domain
build-system, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.