Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflicting detection of executable targets on when using a binaryTarget on an executable product #8101

Open
1 task done
sleepygarden opened this issue Nov 5, 2024 · 0 comments
Labels

Comments

@sleepygarden
Copy link

sleepygarden commented Nov 5, 2024

Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?

  • Confirmed reproduction steps with SwiftPM CLI. The description text must include reproduction steps with either of command-line SwiftPM commands, swift build, swift test, swift package etc.

Description

When I call swift package describe on a package which has an executable product which is just a proxy to a binaryTarget, the command fails because executable product is identified as missing an executable target.
ex:

    products: [ .executable(name: "ForwardedSourcery", targets: ["SourceryTool"]), ],
    targets: [
        .binaryTarget(
            name: "SourceryTool",
            url: "https://github.com/krzysztofzablocki/Sourcery/releases/download/2.0.2/sourcery-2.0.2.artifactbundle.zip",
            checksum: "28d2c35db0cdb0c242b4faa042c137ede4f1d4d242b77ee6363530d3a23d6baf"
        ),
    ]

error: 'bugrepro': executable product 'ForwardedSourcery' expects target 'SourceryTool' to be executable; an executable target requires a 'main.swift' file

If I then add an explicit main.swift file, I get a conflicting error when resolving the package graph: the executable product has two executable targets, and should only have one.
ex:

    products: [ .executable(name: "ForwardedSourcery", targets: ["SourceryTool", "SourceryProxy"]), ],
    targets: [
        .executableTarget(name: "SourceryProxy"),
        .binaryTarget(
            name: "SourceryTool",
            url: "https://github.com/krzysztofzablocki/Sourcery/releases/download/2.0.2/sourcery-2.0.2.artifactbundle.zip",
            checksum: "28d2c35db0cdb0c242b4faa042c137ede4f1d4d242b77ee6363530d3a23d6baf"
        ),
    ]

executable product 'ForwardedSourcery' should not have more than one executable target

These two errors are at odds with each other - is a binaryTarget an executable target or not?

Expected behavior

binaryTarget should be appropriately identified as an executable target, or have the ability to opt-in/out to being identified as an executable target if automatic detection is impossible.

Actual behavior

binaryTarget counting as an executable target will change depending on context.

Steps to reproduce

Sample project attached

BugRepro.zip

Swift Package Manager version/commit hash

Swift Package Manager - Swift 6.0.0-dev

Swift & OS version (output of swift --version ; uname -a)

swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
Target: arm64-apple-macosx14.0
Darwin US-PA-A-MCORN 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6030 arm64

@sleepygarden sleepygarden changed the title Conflicting detection of executable targets on when using a binaryTarget on a executable product Conflicting detection of executable targets on when using a binaryTarget on an executable product Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant