I am new to contributing to Swift and I have tried to build the project in my machine, but I am getting a few errors and I don't know how to fix them. I built the project using the script in this documentation: https://github.com/apple/swift/blob/main/docs/HowToGuides/GettingStarted.md#using-ninja-with-xcode and now I am trying to run a simple swift file to test if everything is alright, but I get the following errors:
Currently my project is set up like this:
I would like to know if someone has ever faced this problem and could help me to find a solution. I tried to build the project from scratch twice and I always get this same error. I would appreciate any support. Thanks in advance!
I'm not sure if building the toolchain with Xcode is as well maintained as the plain CMake+Ninja build. To my knowledge the Xcode configuration is not tested on CI and tends to regress. Do you see any errors when building with CMake and ninja described in the section I linked?
I've seen that before when we used to have a full build using
--xcode, the paths where it looks for the llvm libraries were broken. With that said I think you are trying to build the front-end target that comes with Swift project given those paths are for the libraries at the Xcode build.
Make sure that the
swift-frontend target in the external build system one (the ninja target) is the one building:
As we can see in the image there are two of them, so is easy to mistake both.
I tried to change schemes and I am now using this one, which is the one I created with the external build for the swift-frontend project:
The project seems to build successfully, but nothing is shown in the console:
I am passing the file path in the arguments:
I basically want to run a simple hello world in test.swift using this local compiler to see if everything is alright, but It isn't working out. Do you have any idea what is the problem? I thought it could be the path to the file, but I tried different ones and I wasn't able to see the result in the console.
I saw some people commenting xcode is a bit problematic to run and debug and it is only recommended for navigation, but I am not familiar yet how I can run and test files in the project using the terminal instead. I was able to successfully build the project using the script in the documentation:
How can I run a project using the local compiler I cloned from the github now? I just want to run a hello world in a test.swift file to guarantee I set up everything correctly.
Looking at the screenshots, I can see the schemes are configured to build 2 and even 3 targets, which is likely the reason you are having these build issues. The only target it should build is the one you created manually.
You need to select the executable the scheme will run in the Run action settings (this is the next step in the guide after creating a new scheme).
When building with
ninja on the command line with
build-script, the freshly built compiler would appear at a location that looks like
You may need to adjust it if you passed release/debug configuration flags to
utils/build-script or if you're building on a different platform, e.g. Intel Mac or Linux.