# \[Stuck Newbie Needs Help\] Can't run bin/swiftc

**URL:** <https://forums.swift.org/t/stuck-newbie-needs-help-cant-run-bin-swiftc/59280>\
**Category:** Compiler\
**Tags:** xcode, help-needed, buildin-the-compiler\
**Created:** [July 28, 2022, 11:41am UTC](https://forums.swift.org/t/stuck-newbie-needs-help-cant-run-bin-swiftc/59280 "2022-07-28T11:41:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielfalbo](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/danielfalbo/32/24195_2.png) [@danielfalbo](https://forums.swift.org/u/danielfalbo)\
**Post date:** [July 28, 2022, 11:41am UTC](https://forums.swift.org/t/stuck-newbie-needs-help-cant-run-bin-swiftc/59280/1 "2022-07-28T11:41:29Z")

</div>

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](https://forums.swift.org/t/stuck-newbie-needs-help-cant-generate-xcode-project/58971/2) are in the

```swift
build/Ninja-.../swift-macosx-arm64/bootstrapping0/bin

```

directory (why not right in `build/Ninja-.../swift-macosx-arm64/bin`? I followed [these instructions](https://github.com/apple/swift/blob/main/docs/DevelopmentTips.md#using-ninja-with-xcode))

Anyway, if I try to interpret a file, running

```swift
path/to/my/bin/swiftc /path/to/file.swift

```

, I get

```plaintext
error: unable to load standard library for target 'arm64-apple-macosx12.0'

```

 ![Screenshot 2022-07-28 at 13.32.24](https://global.discourse-cdn.com/swift/original/3X/c/b/cba2ec39811f24179ad8ed6dd216b1ddcd22b77c.png)

Some people on the internet say that just restarting Xcode worked for them for similar issues. Didn't work for me.

I also tried using `bin/swift-frontend -interpret`.

---

<div class="post-metadata">

**Author:** ![danielfalbo](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/danielfalbo/32/24195_2.png) [@danielfalbo](https://forums.swift.org/u/danielfalbo)\
**Post date:** [July 28, 2022, 10:45pm UTC](https://forums.swift.org/t/stuck-newbie-needs-help-cant-run-bin-swiftc/59280/2 "2022-07-28T22:45:15Z")

</div>

Built with [this](https://forums.swift.org/t/swift-mentee-in-the-swift-org-mentorship-program-having-trouble-compiling-the-swift-compiler-please-help/59240/2) command, not getting that error anymore 👍

---

<div class="post-metadata">

**Author:** ![anthonylatsis](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/anthonylatsis/32/39232_2.png) [@anthonylatsis](https://forums.swift.org/u/anthonylatsis)\
**Post date:** [July 29, 2022, 4:04am UTC](https://forums.swift.org/t/stuck-newbie-needs-help-cant-run-bin-swiftc/59280/3 "2022-07-29T04:04:35Z")

</div>

> [@danielfalbo](#):
>
> ![Screenshot 2022-07-28 at 13.32.24](https://global.discourse-cdn.com/swift/original/3X/c/b/cba2ec39811f24179ad8ed6dd216b1ddcd22b77c.png)

A small piece of the compiler has recently been [implemented in Swift](https://github.com/apple/swift/tree/main/SwiftCompilerSources). Hence to build `swift-frontend` _with_ 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)`.

> [@danielfalbo](#):
>
> I found that the binaries built by [Xcode](https://forums.swift.org/t/stuck-newbie-needs-help-cant-generate-xcode-project/58971/2) are in the
> 
> ```swift
> build/Ninja-.../swift-macosx-arm64/bootstrapping0/bin
> 
> ```
> 
> directory (why not right in `build/Ninja-.../swift-macosx-arm64/bin`?

Is there no `swift-frontend` binary in `build/Ninja-.../swift-macosx-arm64/bin`?

---

<div class="post-metadata">

**Author:** ![danielfalbo](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/danielfalbo/32/24195_2.png) [@danielfalbo](https://forums.swift.org/u/danielfalbo)\
**Post date:** [July 29, 2022, 6:25am UTC](https://forums.swift.org/t/stuck-newbie-needs-help-cant-run-bin-swiftc/59280/4 "2022-07-29T06:25:59Z")

</div>

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!

```bash
# 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.

---

<div class="post-metadata">

**Author:** ![anthonylatsis](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/anthonylatsis/32/39232_2.png) [@anthonylatsis](https://forums.swift.org/u/anthonylatsis)\
**Post date:** [August 2, 2022, 8:05pm UTC](https://forums.swift.org/t/stuck-newbie-needs-help-cant-run-bin-swiftc/59280/5 "2022-08-02T20:05:21Z")

</div>

> [@danielfalbo](#):
>
> 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.

You can work around this issue by passing the `--bootstrapping=off` option to build-script.
