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
Freshly install macOS Montarey
Install xcode developer tools (not xcode itself)
open command line
Run swift —version. This outputs 5.7
In empty temporary folder run swift package init
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.
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.