swiftlang / swift-package-manager

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

`swift build` results in `PlatformPath` warning from `xcrun`, fails completely for some #7480

Open timoffex opened 7 months ago

timoffex commented 7 months ago

Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?

Description

When I use swift build to build a simple package (just this: https://github.com/wandb/wandb/tree/main/apple_stats), I see the following warning in the terminal:

  warning: could not determine XCTest paths: terminated(1): /usr/bin/xcrun --sdk macosx --show-sdk-platform-path output:
      xcrun: error: unable to lookup item 'PlatformPath' from command line tools installation
      xcrun: error: unable to lookup item 'PlatformPath' in SDK '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'

For some coworkers, this is an error instead of a warning, failing the build completely.

I'm guessing this is a version issue, but it's difficult to figure out online how/what to upgrade for those who get an error. I also do not understand why there is a warning at all.

Expected behavior

No warning and no error. It should just build.

Actual behavior

A warning for some; an error for others.

Steps to reproduce

  1. Download this folder https://github.com/wandb/wandb/tree/main/apple_stats
  2. cd into it and run swift build

Swift Package Manager version/commit hash

No response

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

Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4) Target: arm64-apple-darwin23.1.0 Darwin Timofey-Peshin-K50H236L02.local 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct 9 21:33:00 PDT 2023; root:xnu-10002.41.9~7/RELEASE_ARM64_T6031 arm64

timoffex commented 7 months ago

softwareupdate --install "Command Line Tools for Xcode-15.3" turns the error into a warning for at least one person.

kevherro commented 3 months ago

I encountered a similar issue on Xcode 16 beta 6 and macOS Sequoia Version 15.0 Beta (24A5327a). If you have Xcode installed, try using it instead of the Command Line Tools:

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

Note: Replace Xcode.app with Xcode-beta.app if you're using a beta version.

Xcode provides a more comprehensive development environment than the Command Line Tools, including all necessary SDKs, frameworks, and tools. This often resolves XCTest and other development-related issues. I hope this helps!