Uploaded image for project: 'Swift'
  1. Swift
  2. SR-13761

Swift Package Manager requires macOS version from Linux only dependency

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Package Manager
    • Labels:
      None
    • Environment:

      Apple Swift version 5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1)
      Target: x86_64-apple-darwin19.6.0

      Description

      If a swift package includes a dependency that has a condition to be Linux only the platform requirements of that dependent package are still applied to other platforms.

      The following Package.swift contains a dependency on apple/swift-crypto but only for Linux.

      // swift-tools-version:5.3
      
      import PackageDescription
      
      let package = Package(
          name: "swift-5.3-deps",
          products: [
              .library(name: "swift-5.3-deps", targets: ["swift-5.3-deps"]),
          ],
          dependencies: [
              .package(url: "https://github.com/apple/swift-crypto.git", from: "1.0.0"),
          ],
          targets: [
              .target(
                  name: "swift-5.3-deps",
                  dependencies: [.product(name: "Crypto", package: "swift-crypto", condition: .when(platforms: [.linux]))]),
          ]
      )
      

      When I run `swift build` I get the following error even though I am not linking swift-crypto into the macOS version of my library.

      error: the library 'swift-5.3-deps' requires macos 10.10, but depends on the product 'Crypto' which requires macos 10.15; consider changing the library 'swift-5.3-deps' to require macos 10.15 or later, or the product 'Crypto' to require macos 10.10 or earlier.
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            adamfowlerphoto Adam Fowler
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated: