Is there a way to debug swift package manager in Xcode?

Something got broken in swift package manager starting from 5.2 on macOS - for some C system libraries that export pkg-config files swiftpm fails to find the appropriate .pc file. Tho on 5.1 it works fine. I'm experiencing this while using library called pango (, available thru brew ton install locally). The same toolchain version on linux resolves headers and c-flags correctly.
So i wanted to debug the swift package manager itself. I tried both opening Package.swift of swift pm in Xcode 11.5 and generating an Xcode project, but swift-build (well, swiftc launched by swift-build) built from Xcode fails to compile the manifest file with error Package.swift:9:8: error: no such module 'PackageDescription' on the targeted manifest file.
What am I doing wrong here?

How are you attempting to launch Swift-build? Can you also open a ticket on for the big you have found?

hey @hartbit
First things first I've created a bug for this one: I've added a sample project as an original issue showcase.

How are you attempting to launch Swift-build?

Literally got full swift source code via github repo and clone tool. I tried both the 5.2.4 release tag and master. After that i tried opening the Package.swift from swiftpm directory, got Xcode to generate schemas. In the schema editor I've added two command line arguments:

  • "-v"
  • "--package-path </path/to/package/with/issue>"
    And hit run. Got the swiftc error. Then tried swift package generate-xcodeproj, open that project, do same thing with command line arguments, hit run, swiftc error.

Honestly, I would prefer finding and fixing the original issue myself and creating a pull request because it blocks development of my pet project (i need the "resources" feature from swiftpm 5.3) rather than waiting till someone else fixes it, but I don't see a way to actually debug the swiftpm itself.

I'll look into resolving reproducing and resolving your swift-build issue. I'd love to see more contribution to SwiftPM :slight_smile:

1 Like

Not sure if this is exactly the same 'no such module 'PackageDescription' error, but I found a cheap workaround when I was trying to Run swift-package from Xcode is to modify the swift-package-manager Package.swift file to set PackageDescription product as a dependency for swift-package target.

I had otherwise been able to execute tests, and build ok on both macOS and nightly-5.3-bionic. Only Run had the issue.

i.e.: (Package.swift line 151)

    /** The main executable provided by SwiftPM */
    name: "swift-package",
    dependencies: ["Commands", "PackageDescription"]),
Terms of Service

Privacy Policy

Cookie Policy