0

In my project I have two dependencies

.package(name: "Web3swift", url: "https://github.com/skywinder/web3swift.git", from: "3.0.6"),
.package(name: "Random", url: "https://github.com/vapor-community/random.git", .upToNextMinor(from: "1.2.0"))

the Random package also has Core dependencies (https://github.com/vapor/core.git), and the target package name Web3swift also has Core in it

let package = Package(
    name: "Web3swift",
    platforms: [
        .macOS(.v10_15), .iOS(.v13)
    ],
    products: [
        .library(name: "web3swift", targets: ["web3swift"])
    ],
    dependencies: [
        .package(url: "https://github.com/attaswift/BigInt.git", .upToNextMinor(from: "5.3.0")),
        .package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", .upToNextMinor(from: "1.5.1"))
    ],
    targets: [
        .target(name: "secp256k1"),
        .target(
            name: "Core",
            dependencies: ["BigInt", "secp256k1", "CryptoSwift"]
        ),
        .target(
            name: "web3swift",
            dependencies: ["Core", "BigInt", "secp256k1"],
            exclude: excludeFiles,
            resources: [
                .copy("./Browser/browser.js"),
                .copy("./Browser/browser.min.js"),
                .copy("./Browser/wk.bridge.min.js")
            ]
        ),

Now I have a problem:

multiple targets named 'Core' in: 'core', 'web3swift'; consider using the `moduleAliases` parameter in manifest to provide unique names

Can you please explain how to fix this?

akex jeer
  • 57
  • 1
  • 6
  • https://github.com/apple/swift-evolution/blob/main/proposals/0339-module-aliasing-for-disambiguation.md ? – Larme Nov 16 '22 at 11:19
  • Please explain the `target(name: "Core", dependencies: []` - part. Do you also want to have a target called "Core"? – baronfac Nov 16 '22 at 13:37
  • @baronfac no, I just want install `Web3swift` library and `Random` library, but I get the error – akex jeer Nov 16 '22 at 13:42
  • @Larme I tried `.target( name: "App", dependencies: [ .product(name: "Random", package: "Random", moduleAliases: ["Core": "SCore"]), .product(name: "web3swift", package: "Web3swift") ] ),` but get a error 'product(name:package:moduleAliases:condition:)' is unavailable – akex jeer Nov 16 '22 at 13:42
  • let me write out a full answer – baronfac Nov 16 '22 at 13:44
  • The only solution I found might be these options here: https://stackoverflow.com/questions/71797358/swift-package-resolution-failed-because-multiple-targets-named-a-same-framework – baronfac Nov 16 '22 at 14:10
  • Does this answer your question? [Swift Package Resolution failed because multiple targets named a same framework](https://stackoverflow.com/questions/71797358/swift-package-resolution-failed-because-multiple-targets-named-a-same-framework) – Sihad Begovic Nov 18 '22 at 09:24

1 Answers1

0

When you look at the developer documentation, you'll note that this is only supported in Swift 5.7+. To fix the "...is unavailable" message, you'll need to update the header in Package.swift to: // swift-tools-version:5.7 (also requires XCode > 14).

For full details, you can refer to:

  1. The Swift 5.7 release notes
  2. The evolution proposal: SE-0339

AFAICT, your changes look correct.

como
  • 1