swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.63k stars 10.37k forks source link

error: unable to load standard library for target #77520

Open iMostfa opened 1 week ago

iMostfa commented 1 week ago

Description

Hello,

i faced an error with my local build on MacOS where it outputs error: unable to load standard library for target 'arm64-apple-macosx15.0' when i execute swift-frontend

honestly, i don't know why, most likely it's a problem on my end.

Reproduction

swift-frontend -dump-ast /path/to/file.swift

Expected behavior

i expect it work, and dump the ast, instead i get

Environment

Swift version 6.1-dev effective-5.10 (LLVM d1d2bfa54bdb520, Swift 5708d19e629a4c6)

Additional information

the only workaround about this problem is passing the SDK to swift-frontend. something like this:

swift-frontend -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk -dump-ast /path/to/file.swift 

on first run it takes a lot of time (+10 minutes) but then it works instantly. i think the initial delay is a typical MacOS security stuff.

maybe another solution for this problem would be rebuilding the toolchain. i'm not sure.

iMostfa commented 1 week ago

i'm opening this Bug at least as a reminder for my future self, because this's the 2nd time i lose ~hours trying to debug this problem.

i would be grateful of any insights around this problem.