swiftlang / swift-package-manager

The Package Manager for the Swift Programming Language
Apache License 2.0
9.74k stars 1.34k forks source link

`swift build` fails on macOS without Xcode #7306

Open abeldemoz opened 9 months ago

abeldemoz commented 9 months ago

Description

When attempting to run the swift build command on macOS without Xcode installed, it fails because it cannot find the module CompilerPluginSupport which is imported in the manifest. Here's the error I've gotten:

error: 'swift-testing': Invalid manifest ... /Users/abeldemoz/Desktop/swift-packages/swift-testing/Package.swift:14:8: error: no such module 'CompilerPluginSupport' import CompilerPluginSupport

error: ExitCode(rawValue: 1)

Expected behavior

A successful build is expected.

Actual behavior

Observed behaviour is a build failure. Details below below:

error: 'swift-testing': Invalid manifest ... /Users/abeldemoz/Desktop/swift-packages/swift-testing/Package.swift:14:8: error: no such module 'CompilerPluginSupport' import CompilerPluginSupport

error: ExitCode(rawValue: 1)

Steps to reproduce

  1. Delete the Xcode application by moving it to the bin and emptying the bin. If you have multiple versions of Xcode installed, delete all of them
  2. Open Terminal and install Command Line Tools by running the command xcode-select --install
  3. Navigate to the directory of the 'swift-testing' package or any package that depends on 'swift-testing'
  4. Run the swift build command

swift-testing version/commit hash

Commit hash: 74de1e0bb07d48cb28617f2dbcaf114261a18a6b

Swift & OS version (output of swift --version ; uname -a)

Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5) Target: arm64-apple-darwin23.1.0 Darwin Abels-MacBook-Pro.local 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct 9 21:27:24 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6000 arm64

stmontgomery commented 9 months ago

Hi @abeldemoz, thanks for giving the package a try. As noted in our Getting Started documentation, we only support using swift-testing with Swift main development snapshot toolchains right now. Can you ensure you are following those instructions and check whether this reproduces?

I am marking this issue as closed since we believe this works using those steps, but we can reopen the issue if you are still experiencing it.

abeldemoz commented 9 months ago

Hi @abeldemoz, thanks for giving the package a try. As noted in our Getting Started documentation, we only support using swift-testing with Swift main development snapshot toolchains right now. Can you ensure you are following those instructions and check whether this reproduces?

I am marking this issue as closed since we believe this works using those steps, but we can reopen the issue if you are still experiencing it.

Hi @stmontgomery, thanks for taking a look at the issue. Unfortunately, the problem still persists when using the latest development snapshot toolchain. I'm currently using "swift-DEVELOPMENT-SNAPSHOT-2024-01-22-a.xctoolchain" and the following Swift version

Apple Swift version 5.11-dev (LLVM 79aab1b6aed58d0, Swift fd9726839309a33)`
Target: arm64-apple-macosx14.0
grynspan commented 9 months ago

Reopening and sending to SwiftPM as the missing module issue is on their end.

neonichu commented 9 months ago

Sounds like the issue is specific to the Command Line Tools package, not the open source toolchain.