Skip to content

Duplicate main symbol for swift test on Windows #6367

Open
@remko

Description

@remko

Description

I have a package with an executable target, and a test target. The tests in the test target do a @testable import of the executable target. The main target has a @main struct ....

Running swift test works on macOS and Linux.
Running swift test on Windows fails.

Expected behavior

When running swift test on Windows, the tests run.

Actual behavior

When running swift test on windows, it fails with an error at link time:

lld-link: error: duplicate symbol: main
>>> defined at C:\\...\\MyPackageTests.build\\runner.swift.o
>>> defined at C:\\...\\MyPackage\\MyMainStruct.swift.o

Steps to reproduce

No response

Swift Package Manager version/commit hash

version included in the official Swift download for Windows

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

Swift: 5.8
OS: Microsoft Windows Server 2022

(also happens on other versions of swift and OS).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions