SPM support missing on Monterey without Xcode - no such module PackageDescription

Context is that I try to convince web developers to use command line tools I wrote in swift. The problem I face is that they do not want to install Xcode and I want them to use Swift package manager to run my tools.

So how to reproduce the issue

  1. Freshly install macOS Montarey
  2. Install xcode developer tools (not xcode itself)
  3. open command line
  4. Run swift —version. This outputs 5.7
  5. In empty temporary folder run swift package init
  6. In same folder run swift build

Then

It outputs

error: '<#package#>': Invalid manifest
error: no such module 'PackageDescription'
...

Tried to resolve it by installing Visual Studio Code extension for Swift from Swift Server workgroup and same issue.

Name: Swift
Id: sswg.swift-lang
Description: Swift Language Support for Visual Studio Code.
Version: 0.8.2
Publisher: Swift Server Work Group
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang

This is really problematic for selling Swift in a corporate environment.

1 Like

I don't know what the issue is, but I'd recommend two things:

  1. Check what happens if you explicitly install Swift's toolchain from the webite
  2. Distribute the code to the web developers as a binary, not as code.

Could you try running xcode-select --reset and see if that helps?

It is difficult to produce the error as you need a clean install of a machine. But I have another engineer who switched today and will let him do this.

The only workaround we found today is install xcode and select it.

What leaves me puzzled is that macos comes with swift build in. But it seams that this is a slimmed down version, not supporting building and swift package manager. Would it not be a nice addition that you could install swift package manager support instead of having to install xcode?

Like mentionned it is possible on linux to have a version of swift that supports running swift and another that supports building it. So I guess it should be possible?

So the reset worked but I think only because the dev already installed xcode on his new machine. My question was how to make swift work without installing xcode.

Will test if a new dev with a new mac comes along. Thanks for the help.

I have the same issue as outlined in your opening post, and can confirm that:

sudo xcode-select --reset

...does NOT fix things.

I don't have the Xcode application installed, only Xcode Command Line Tools. This is on Ventura now.

I also tried deleting the /Library/Developer/CommandLineTools directory and reinstalling it (xcode-select --install) and that made no difference.

1 Like

very annoying, I still have not solution for it

other then installing xcode