I tried to play around with the code in Version.cpp to see if the changes I was making to the codebase were actually working on the build (by running swift --version). I found that the binaries built by Xcode are in the
A small piece of the compiler has recently been implemented in Swift. Hence to build swift-frontendwith Swift sources, we must now first build a version of swift-frontend that excludes them (or use a compiler from a pre-installed Swift toolchain). bootstrapping0/bin is where the latter so-called level-0 swift-frontend winds up. This error pops out because there is no Standard Library module built for the level-0 compiler. You are still welcome to grab the host system Standard Library with xcrun -sdk macosx .../bootstrapping0/bin/swift-frontend or .../bootstrapping0/bin/swift-frontend -sdk $(xcrun --show-sdk-path).
Is there no swift-frontend binary in build/Ninja-.../swift-macosx-arm64/bin?
When I used Xcode, I did have a build/Ninja-.../swift-macosx-arm64/bin but it did not update with my code changes when I rebuilt the project with cmd + b, only build/Ninja-.../swift-macosx-arm64/bootstrapping0/bin used to reflect my code changes.
I gave up on using Xcode now, I'll just use a naked text editor like Vim or Vscode and see warnings and errors when compiling in the terminal.
I'm using the following commands and everything is finally working fine!
# Clean first build
utils/build-script --release --debug-swift --clean
# Incremental build
ninja -C ../build/Ninja-ReleaseAssert+swift-DebugAssert/swift-macosx-arm64 && ../build/Ninja-ReleaseAssert+swift-DebugAssert/swift-macosx-arm64/bin/swiftc --version
# Compile and run main.swift file
../build/Ninja-ReleaseAssert+swift-DebugAssert/swift-macosx-arm64/bin/swiftc -sdk $(xcrun --show-sdk-path) && ./main
Thank you much for your help, those are exactly the pointers I needed.