1
votes

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

2 Answers

0
votes

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.

0
votes

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.