yonaskolb / yonaskolb/XcodeGen

SwiftPM packages linked into static libraries (bug)

Open
#748 6 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

Hey! I seem to have ran into a bug with the SwiftPM package integration for static libraries. When a static library depends on an SDK (e.g. Foundation, UIKit, …) all SwiftPM packages will also be linked into it. Adding other types of dependencies doesn’t seem to have any impact. It seems like it’s only when a static library depends on both a SwiftPM package and an SDK that the issue occurs.

In my case it caused just over 3000 duplicate symbol errors. As both my app and static library target linked with Alamofire from SwiftPM 😅

I was able to reproduce with latest master. See an example using this small modification of the SPM test fixture:

name: SPM
packages:
  Codability:
    url: https://github.com/yonaskolb/Codability
    majorVersion: 0.2.1
localPackages:
 - ../../.. #XcodeGen itself
targets:
  App:
    type: application
    platform: iOS
    sources: [SPM]
    scheme: {}
    dependencies:
      - package: Codability
      - target: StaticLibrary
  StaticLibrary:
    type: library.static
    platform: iOS
    sources: StaticLibrary
    dependencies:
      - package: Codability
      - sdk: UIKit.framework # <- the addition

Screenshot

Screenshot of Xcode with the incorrect linkage of the SwiftPM package

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 SPM test fixture and its modified YAML, reproducing the App and StaticLibrary targets with Codability and UIKit.framework dependencies. Trace the generated Xcode project and verify that the SwiftPM package is not linked redundantly into the static library, eliminating the duplicate symbol errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
build-system, mobile-dev
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.