Skip to content

Swift Build requires at least one toolchain installed in the system on macOS #357

Open
@cmcgee1024

Description

@cmcgee1024

I am using the swiftly toolchain manager, which installs only open source macOS toolchains and they are all installed in the current user's home directory ~/Library/Developer/Toolchains, not in /Library/Developer/Toolchains. I do not have any toolchains installed in the system.

When trying to build with Swift Build in this environment with the current latest main snapshot (main-snapshot-2025-03-25) that has the swiftbuild build system I get the following error initially:

% swift build --build-system=swiftbuild
error: failed to load toolchains in /Library/Developer/CommandLineTools/Toolchains: Error Domain=NSCocoaErrorDomain Code=260 "The folder “Toolchains” doesn’t exist." UserInfo={NSUserStringVariant=(
    Folder
), NSFilePath=/Library/Developer/CommandLineTools/Toolchains, NSURL=file:///Library/Developer/CommandLineTools/Toolchains, NSUnderlyingError=0x600001f2cf90 {Error Domain=NSOSStatusErrorDomain Code=-43 "fnfErr: File not found"}}
error: missing required default toolchain
error: Could not initialize build system

After manually creating an empty directory in there the error becomes the following:

% swift build --build-system=swiftbuild                    
error: missing required default toolchain
error: Could not initialize build system

It seems that Swift Build requires that there is at least one default toolchain installed on the system.

Expected result:
Because it is bundled with the Swift toolchain it should be able to find its own toolchain, even if it is in the user's home directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions