Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-14972] SwiftPM describe does not include target dependencies #4399

Closed
swift-ci opened this issue Jul 24, 2021 · 5 comments
Closed

[SR-14972] SwiftPM describe does not include target dependencies #4399

swift-ci opened this issue Jul 24, 2021 · 5 comments
Labels

Comments

@swift-ci
Copy link
Contributor

@swift-ci swift-ci commented Jul 24, 2021

Previous ID SR-14972
Radar rdar://problem/81130263
Original Reporter kielgillard (JIRA User)
Type Bug
Status Resolved
Resolution Invalid

Attachment: Download

Environment

Xcode 12.5.1

Apple Swift version 5.4.2 (swiftlang-1205.0.28.2 clang-1205.0.19.57)
Target: x86_64-apple-darwin20.6.0

Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug
Assignee None
Priority Medium

md5: 461cdc7ea06b5a3a2a2f5bc9a2fb56fc

Issue Description:

`swift package describe --type json` generates an empty array for `target_dependencies` fields. But `swift package dump-package` produces the correct JSON output. This is inconsistent. As a developer, I do not know which command I should rely on.

Details

Using the attached sample package, with a dependency on `swift-collections`, I get this JSON output with the `swift package describe --type json` command:

{
  "dependencies" : [
    {
      "name" : "swift-collections",
      "requirement" : {
        "range" : [
          {
            "lower_bound" : "0.0.1",
            "upper_bound" : "1.0.0"
          }
        ]
      },
      "url" : "https://github.com/apple/swift-collections"
    }
  ],
  "name" : "bugpackage",
  "path" : "/Users/kgillard/bugpackage",
  "platforms" : [

  ],
  "products" : [
    {
      "name" : "bugpackage",
      "targets" : [
        "bugpackage"
      ],
      "type" : {
        "library" : [
          "automatic"
        ]
      }
    }
  ],
  "targets" : [
    {
      "c99name" : "bugpackageTests",
      "module_type" : "SwiftTarget",
      "name" : "bugpackageTests",
      "path" : "Tests/bugpackageTests",
      "sources" : [
        "bugpackageTests.swift"
      ],
      "target_dependencies" : [
        "bugpackage"
      ],
      "type" : "test"
    },
    {
      "c99name" : "bugpackage",
      "module_type" : "SwiftTarget",
      "name" : "bugpackage",
      "path" : "Sources/bugpackage",
      "product_memberships" : [
        "bugpackage"
      ],
      "sources" : [
        "bugpackage.swift"
      ],
      "target_dependencies" : [

      ],
      "type" : "library"
    }
  ],
  "tools_version" : "5.3"
}

When I use `swift package dump-package`, I see the dependency listed:

{
  "cLanguageStandard" : null,
  "cxxLanguageStandard" : null,
  "dependencies" : [
    {
      "explicitName" : "swift-collections",
      "name" : "swift-collections",
      "productFilter" : null,
      "requirement" : {
        "range" : [
          {
            "lowerBound" : "0.0.1",
            "upperBound" : "1.0.0"
          }
        ]
      },
      "url" : "https://github.com/apple/swift-collections"
    }
  ],
  "name" : "bugpackage",
  "packageKind" : "root",
  "pkgConfig" : null,
  "platforms" : [

  ],
  "products" : [
    {
      "name" : "bugpackage",
      "targets" : [
        "bugpackage"
      ],
      "type" : {
        "library" : [
          "automatic"
        ]
      }
    }
  ],
  "providers" : null,
  "swiftLanguageVersions" : null,
  "targets" : [
    {
      "dependencies" : [
        {
          "product" : [
            "Collections",
            "swift-collections",
            null
          ]
        }
      ],
      "exclude" : [

      ],
      "name" : "bugpackage",
      "resources" : [

      ],
      "settings" : [

      ],
      "type" : "regular"
    },
    {
      "dependencies" : [
        {
          "byName" : [
            "bugpackage",
            null
          ]
        }
      ],
      "exclude" : [

      ],
      "name" : "bugpackageTests",
      "resources" : [

      ],
      "settings" : [

      ],
      "type" : "test"
    }
  ],
  "toolsVersion" : {
    "_version" : "5.3.0"
  }
}
@swift-ci
Copy link
Contributor Author

@swift-ci swift-ci commented Jul 25, 2021

Comment by Kiel (JIRA)

Further, notice the dump package command does not list the sources for the target but the describe command does. This is frustrating to work with when you need to provide a tool a description of a target and its dependencies.

@typesanitizer
Copy link

@typesanitizer typesanitizer commented Jul 26, 2021

@swift-ci create

@neonichu
Copy link
Member

@neonichu neonichu commented Jul 27, 2021

`dump-package` shows the manifest contents vs. `describe` looks at the entire package, so `dump-package` can't actually show information about on-disk source files.

It also seems right that `target_dependencies` is empty, the target in question doesn't have any target dependencies, as far as I can see. What should be there, though, is an entry in `product_dependencies` for the dependency on the "Collections" product from the "swift-collections" package. That seems like a bug to me.

I think it also could make sense to convey via the help text what the difference between the two commands is.

@neonichu
Copy link
Member

@neonichu neonichu commented Jul 27, 2021

I can reproduce the issue in 5.4, but it seems fixed already in 5.5:

{
  "dependencies" : [
    {
      "identity" : "swift-collections",
      "name" : "swift-collections",
      "requirement" : {
        "range" : [
          {
            "lower_bound" : "0.0.1",
            "upper_bound" : "1.0.0"
          }
        ]
      },
      "url" : "https://github.com/apple/swift-collections"
    }
  ],
  "name" : "bugpackage",
  "path" : "/Users/neonacho/Downloads/bugpackage",
  "platforms" : [

  ],
  "products" : [
    {
      "name" : "bugpackage",
      "targets" : [
        "bugpackage"
      ],
      "type" : {
        "library" : [
          "automatic"
        ]
      }
    }
  ],
  "targets" : [
    {
      "c99name" : "bugpackageTests",
      "module_type" : "SwiftTarget",
      "name" : "bugpackageTests",
      "path" : "Tests/bugpackageTests",
      "sources" : [
        "bugpackageTests.swift"
      ],
      "target_dependencies" : [
        "bugpackage"
      ],
      "type" : "test"
    },
    {
      "c99name" : "bugpackage",
      "module_type" : "SwiftTarget",
      "name" : "bugpackage",
      "path" : "Sources/bugpackage",
      "product_dependencies" : [
        "Collections"
      ],
      "product_memberships" : [
        "bugpackage"
      ],
      "sources" : [
        "bugpackage.swift"
      ],
      "type" : "library"
    }
  ],
  "tools_version" : "5.3"
}

@neonichu
Copy link
Member

@neonichu neonichu commented Jul 27, 2021

Resolving as it seems like this is fixed already in 5.5

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants