Options.inc file not found when integrating Xcode with Ninja

Hey everyone!

I'm following the Getting Started Guide to get setup in Xcode. I've completed the Using Ninja with Xcode steps. When I run I get the following error: 'clang/Driver/Options.inc' file not found. I'm able to build/run just fine without Xcode.



M1 Max MBP
macOS 13.1 (22C65)
Xcode 14.2 (14C18)
Project Hashes

Build with Ninja

utils/build-script --skip-build-benchmarks --bootstrapping=off \
  --skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "$(uname -m)" \
  --sccache --debug --swift-disable-dead-stripping

Build for Xcode

utils/build-script --debug --swift-darwin-supported-archs "$(uname -m)" --xcode --clean


Scheme - Info

In that^ picture I three swift-frontend executables:

  1. /Users/benn/git/swift-project/build/Xcode-DebugAssert/swift-macosx-arm64/bootstrapping0/Debug/bin/swift-frontend
  2. /Users/benn/git/swift-project/build/Xcode-DebugAssert/swift-macosx-arm64/bootstrapping1/Debug/bin/swift-frontend
  3. /Users/benn/git/swift-project/build/Xcode-DebugAssert/swift-macosx-arm64/Debug/bin/swift-frontend

Scheme - Arguments

Hi, in my case I built it successfully, but I got the error message.

/Users/karimzhang/Desktop/swift-project/build/SwiftBuildTest/main.swift:8:8: error: no such module 'Foundation'
import Foundation
<unknown>:0: note: did you forget to set an SDK using -sdk or SDKROOT?
<unknown>:0: note: use "xcrun swiftc" to select the default macOS SDK installed with Xcode
Program ended with exit code: 1

Build with Ninja

utils/build-script --skip-build-benchmarks \
  --skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "$(uname -m)" \
  --sccache --release-debuginfo --swift-disable-dead-stripping

Build for Xcode

utils/build-script --swift-darwin-supported-archs "$(uname -m)" --xcode --clean


Scheme - Info

Scheme - Arguments

I'm still looking for a solution, can anyone help me?Thank

swift-frontend doesn’t know where to look for an SDK to import Foundation. You can pass the SDK path to swift-frontend using the -sdk option, e.g.

-sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk

But if you imported Foundation by habit and the import is unused, you may as well just remove it instead; the Standard Library is imported implicitly.

Hello @benn, I’m sorry this thread has gone unnoticed for so long! We ought to add an afterword to the guide telling you who to tag for questions on the forums.

For what it’s worth, the scheme editor screenshots show that the Build action has 2 targets, which is probably why the build was failing. The scheme should be set up to build a single target — the one you configured manually.

Hi,thank for you help,it worked!

Hi @anthonylatsis ,actullay I’d like to learn more about how JSONDecoder works,It looks like it's inside the foundation, does that mean I can't debug it?
But it looks like he's open source, and I'm confused.swift-corelibs-foundation/JSONEncoder.swift at main · apple/swift-corelibs-foundation · GitHub

Quoting the README:

This project, swift-corelibs-foundation, provides an implementation of the Foundation API for platforms where there is no Objective-C runtime. On macOS, iOS, and other Apple platforms, apps should use the Foundation that comes with the operating system. Our goal is for the API in this project to match the OS-provided Foundation and abstract away the exact underlying platform as much as possible.

The Foundation for Darwin platforms is not open-source, but I presume the swift-corelibs-foundation JSONDecoder has a similar implementation.