Swift with Ninja setup error

While attempting to set up Swift with Ninja, I'm running into an error that says "unable to spawn process '/opt/homebrew/bin/ninja' (No such file or directory)".

which ninja gives me /opt/homebrew/bin/ninja as the Build Tool path name and the info panel of my new target currently looks like this:

Does anyone understand what is going on here?

@anthonylatsis requesting your help :)

Looks like you forgot to replace the path/to/swift-project/build portion with the absolute path to your build directory. You can cd your swift-macosx-arm64 directory and invoke pwd to obtain the absolute path.

1 Like

Thank you!

1 Like

I'm running into another issue now. When checking out between branches, the files show the changes but when I build the project, the output continues to be from the main ("unchanged") branch. This is occurring whether I checkout from terminal or from within Xcode. Is there a build setting that I was supposed to set up?

This sounds like the same issue as [Stuck Newbie Needs Help] Can't run bin/swiftc - #4 by danielfalbo — bootstrapping does not work on Apple silicon Macs (no idea why and how). The bug seems to have been around from the start though. Is this your first time spot checking a macosx-arm64 build?

Yes, it is my first time doing this with the Ninja on Xcode setup. Until recently, I was able to use the build script with --xcode to generate the swift-macosx-arm64/Swift.xcodeproj and open that to make changes and build. However that no longer works.

With this setup, I can see the code changes just fine, but cmd+b gives me output for unchanged code in the console.

The bug should not be related to Xcode, because we relay all the building to Ninja. This is even weirder, I was expecting the problem to apply to both Ninja and deprecated Xcode builds, not just Ninja. Anyway, you can work around this by passing the --bootstrapping=off option to the build-script invocation for the Ninja build (needs to be a clean build).

1 Like

This worked for me and I have a functioning project that I can edit and build. Thank you!

1 Like

@anthonylatsis Do you think we should document that in someway on the starter guides? At least recommend people to use --bootstrapping=off while we have this bug(we can remove when this is fixed) because the feeling I have is specially for people building for the first time and trying figure things out, this may be confusing because the side-effect is "why I can't see my changes". WDYT?
I run into this when first try it and took me sometime to understand what was happening, and give up on bootstrapping completely, could never make it work neither with Xcode nor Ninja :joy:


Awesome! Thank you =]

1 Like

After some debugging, I'm now running into an inability to print some variables and this message swift-frontend was compiled with optimization - stepping may behave oddly; variables may not be available.

I've seen this before when Optimization Level settings in Xcode are set to Fast but it seems that settings are set correctly to 0 or None[-Onone] so unsure why this message persists.

That is likely because you probably run ninja command with --release-debuginfo and that means building everything in release mode but with debug information, which in some cases may result in what you are seeing which is that frontend was built in release. You could try --release-debuginfo --debug-swift which means llvm dependencies are still built in release with debug information, but all thing under swift-macosx-arm64 that includes swift-frontend target would be built in debug mode.
Note that it will generate a new folder suffixed with +swift-DebugAssert so it will require adjust the Xcode with ninja setup to point to the paths under this new directory.
Hope that helps =]

Thank you! This solved my issue.

1 Like