1

Lets says:

B is a library which depends on CommonLib
App depends on B and CommonLib

Here are their mainfests

B's Package.swift:

import PackageDescription
let package = Package(
    name: "B",
    products: [
        .library(
            name: "B",
            targets: ["B"]),
    ],
    dependencies: [
      .package(url: "https://.../CommonLib", from: "1.0.0"),
   ],
    targets: [
        .target(
            name: "B",
            dependencies: ["CommonLib"]),
        .testTarget(
            name: "BTests",
            dependencies: ["B"]),
    ]
)

App's Package.swift

import PackageDescription
let package = Package(
    name: "App",
    dependencies: [
      .package(url: "https://.../CommonLib", from: "1.0.0"),
      .package(url: "https://.../B", from: "1.0.0"),
   ],
    targets: [
        .target(
            name: "App",
            dependencies: ["CommonLib", "B"]),
        .testTarget(
            name: "AppTests",
            dependencies: ["App"]),
    ]
)

swift build
error: Found multiple packages with the name CommonLib...

If both App and B depend on CommonLib and if I import B and CommonLib into App there is an error Found multiple packages with the name...

Apple Swift version 4.0.2 (swiftlang-900.0.69.2 clang-900.0.38) Target: x86_64-apple-macosx10.9

Does anyone know how to resolve this?

2 Answers 2

0

Remove Package.pins and rerun swift build. See which packages it is trying to fetch. Check .build/checkouts and .build/dependencies-state.json - which tags and which versions, respectively, of CommonLib, are written there.

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you! I messed up, it was easy to make changes to CommonLib, commit and forget to update git tag. Ended up with two different versions and because of that ... error Found multiple packages with the name...
@vadim-eisenberg I'm having similar issue, but don't understand how this data helps to solve it. Can you please elaborate? In my case in .bulid/dependencies-state.json there are two entries for the same library, pointing to the same commit, but they have different subpath values in which one is called A-numbers1 and the other one A.git-numbers2. Although both referencing the same version of the library.
@Zapko This data is to get some hints about the problem, I do not have an exact algorithm what to look at. I guess the problem is that your A package is referenced differently in some of your dependency packages. For example in one dependency it is referenced by a git url and in another one by an https url. This probably confuses the Swift Package Manager.
0

If you want to manually import these to libraries, you will see this error. You cannot have the multiple packages with the same name.

For solutions, you will have to change the manifest and remove one of them. However I think this can be resolved if you are using CocoaPod, which is the perfect tool to manage packages & libraries. You can also change the manifest easily from CocoaPod.

1 Comment

It's not one manifest. B is separate library to be imported by other executables. There are two distinct manifests App's Package.swift and B's Package.swift. In the case above both of them need to import CommonLib. Then App needs to import B.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.