Search code examples
swiftwarningscompiler-warningsswift-package-manager

Package Loading: "Ignoring duplicate product" (SwiftPM)


I'm trying to build a Swift package using the Swift Package Manager.

However, when I open the package in Xcode and click Run, I get the following warning:

enter image description here

How can I resolve this?


Solution

  • This is an issue often encountered if you are attempting to build a library/framework but also have a main.swift file in your target's root directory, like so:

    enter image description here.

    The presence of a main.swift file makes SwiftPM believe that you are attempting to build a command line tool, and thus complains about the unnecessary (duplicate in name) library produced.

    This warning may be confusing as it does not occur in projects initialized with the dynamic framework template from Xcode, for iOS, macOS, tvOS or watchOS.