Xcode 12 with swift setup first project error in Automatic preview

I am trying to learn SwiftUi. I have just created a new project and already am getting an error in the Automatic preview. The preview failed to build.

The error is...

unable to execute command: Executable "ld" doesn't exist!



LinkDylibError: Failed to build ContentView.swift

Linking failed: unable to execute command: Executable "ld" doesn't exist!

clang-10: error: unable to execute command: Executable "ld" doesn't exist!
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
Did you ever find a solution to this moudstar? Having the same issues and cant find a fix online
@moudstar 
Could you show the code with the line that fails ?
I also get this error. Did you fix it?
This was from a new install of xcode and swift, create new project, try and preview

SOLVED!

In my case, I was using another Toolchain(that I installed to test another Swift SDK, that doesn't matter now), and all I needed to do is setting the Xcode to use the default Toolchain again:

  1. With the Xcode open, on the MenuBar(top of you screen) click on [Xcode]
  2. Click on [Toolchain]
  3. Click on [Manage Toolchain]
  4. Click/Select your Xcode's version. E.G.: In you case: "Xcode 13.2"

[Extra step] I suggest you to uninstall another Toolchain that is not the default after using it, since Xcode can give some errors difficult to detect/understand, and you can do this by doing a ["Right click of your mouse" on those Toolchains ] -> [Move to Trash]

Tags: @moudstar @THPHogg @Claude31 @yezzer

Xcode 12 with swift setup first project error in Automatic preview
 
 
Q