Skip to content

SPM error: duplicate key found: "SourceryExecutable" #1409

@ailinykh

Description

@ailinykh

In case of building a fat binary it fails with duplicate key found error

error: duplicate key found: 'ID(moduleName: "SourceryExecutable", packageIdentity: sourcery, buildTriple: PackageGraph.BuildTriple.destination)'

Prerequisites

Xcode 16.2, macOS Sequoia 15.4, MacBook Pro M2 Max 32 GB
Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx13.0

Steps to reproduce

  1. Create empty directory
mkdir sourcery-duplicate-key-found && cd $_
  1. Initialize a sample SPM project
swift package init
  1. Add Sourcery as a dependency
swift package add-dependency https://github.com/krzysztofzablocki/Sourcery.git --exact 2.2.6
  1. Build milti-arch binary
swift build --arch arm64 --arch x86_64

Expected result

Building for debugging...
[6/6] Compiling sourcery_duplicate_key_found sourcery_duplicate_key_found.swift
Build complete! (4.17s)

Actual result

error: duplicate key found: 'ID(moduleName: "SourceryExecutable", packageIdentity: sourcery, buildTriple: PackageGraph.BuildTriple.destination)'

Solution

Probably, this issue could be resolved by removing this line:

.executable(name: "sourcery", targets: ["SourceryExecutable"]),

however, I believe that there are better solution

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions