Configuring a dev environment

I'm trying to configure a development environment for the SPM project. I've read the instructions in CONTRIBUTING.md. I have Xcode 13.4 installed, and I'm on MacOS 12.4.

I'm trying to use the SPM already installed to build SPM from the cloned project, but I'm facing some issues with some unresolved symbols. Here's a small portion of my terminal logs when I try building SPM using swift build:

swift-package-manager/Sources/Build/SPMSwiftDriverExecutor.swift:45:70: error: cannot find type 'TimePoint' in scope
recordedInputModificationDates: [TypedVirtualPath : TimePoint]) throws -> ProcessResult {

swift-package-manager/Sources/Build/SPMSwiftDriverExecutor.swift:66:70: error: cannot find type 'TimePoint' in scope
recordedInputModificationDates: [TypedVirtualPath : TimePoint]) throws {

If I try using Xcode to build it, it gives me more errors (I'm using the SwiftPM-Package scheme):

Are there any configurations I'm missing?
Thanks in advance.

If you're trying to build the current top of the tree (that is, the latest commit on the main branch), then first and foremost you'll need to download and install a latest swift nightly toolchain. You can download that from Swift.org - Download Swift. Look for the link to Xcode, Universal, Trunk Development (main).

You'll need to install it, and if you want to use Xcode you'll need to activate that chain within Xcode. The instructions for that whole sequence are all in the same link, just a bit lower under installation.

You'll find a lot of the same flow suggested in the contributing docs from the SPM repo as well: swift-package-manager/CONTRIBUTING.md at main · apple/swift-package-manager · GitHub

1 Like

Thank you for the help, Joseph.

I've just installed the latest toolchain, but unfortunately I keep receiving the same errors. I think I'm missing some configuration that's not listed in CONTRIBUTING.md.

I managed to build it from the command line first. I did the following:

  1. export TOOLCHAINS=swift
  2. xcrun --find swift
  3. swift build

After that, my builds using Xcode also worked.

1 Like

I tried the same, but unfortunately I still can't get a successful build:

$ export TOOLCHAINS=swift
$ xcrun --find swift
/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2022-09-12-a.xctoolchain/usr/bin/swift
$ swift build

However, I still see error: cannot find type 'TimePoint' in scope. Could you please tell me which snapshot did you use, i.e. which output do you see for xcrun --find swift?

I've used the trunk development one, for Xcode.

The output of the xcrun --find swift command, after exporting the TOOLCHAINS variable, is /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2022-09-06-a.xctoolchain/usr/bin/swift

Did you select the newly installed toolchain in Xcode as well?

I installed the same toolchain, still no success unfortunately. When I open the Package.swift in Xcode 14.0, then select the toolchain and try to test SwiftPM-Package, I get a different error though: [...]Library/Developer/Xcode/DerivedData/swift-package-manager-heruuddjujodithhrfaclhnrmuph/SourcePackages/checkouts/swift-llbuild/lib/llvm/Support/include/llvm/Support/Chrono.h:104:30: error build: Missing '#include "/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2022-09-06-a.xctoolchain/usr/bin/../include/c++/v1/ratio"'; 'ratio' must be declared before it is used

Which Xcode version do you use?

I'm still on 13.4.1.