Skip to content

Conversation

cmcgee1024
Copy link
Member

@cmcgee1024 cmcgee1024 commented Apr 11, 2025

Add the feature of a special selector "xcode" that can be used like the other swiftly
selectors for some operations, such as swiftly use, and swiftly list, but has no
real effect on other operations.

With this feature, you can swiftly use xcode and then when you run the proxies for
items like swift, clang, and other common toolchain binaries they will be run on the
Xcode toolchain.

swift --version  => /Library/Developer/Toolchains/swift-xyz/usr/bin/swift --version
clang foo.c => /Library/Developer/Toolchains/swift-xyz/usr/bin/swift clang foo.c

When xcode is selected then swiftly run will run with the currently selected xcode
toolchain (or command-line tools) reported by xcrun -f as the toolchain on the path.

When you run swiftly list there is a special entry for "xcode" that is decorated in a
similar way to indicate whether it is the (global) default, and/or in-use toolchain as a
result of the selection mechanism.

@cmcgee1024
Copy link
Member Author

@swift-ci test macOS

@cmcgee1024 cmcgee1024 changed the title Create a special xcode selector that will delegates to xcrun for macOS Create a special Xcode selector for macOS Jul 9, 2025
@cmcgee1024 cmcgee1024 marked this pull request as ready for review July 29, 2025 15:46
Copy link
Member

@etcwilde etcwilde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the question about whether we want to verify that we actually have and Xcode/CommandLineTools toolchain installed, LGTM.


public func listInstalledToolchains(selector: ToolchainSelector?) -> [ToolchainVersion] {
#if os(macOS)
let systemToolchains: [ToolchainVersion] = [.xcodeVersion]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Xcode guaranteed to be installed where swiftly is installed? Should we query to ensure that there is a toolchain installed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Xcode isn't installed then this will end up prompting the user on the console to install the CLT, and then that could be the system Xcode toolchain that it uses. Otherwise, if the user installs an Xcode, and either sets it with xcode-select or sets the DEVELOPER_DIR then swiftly will start proxying to that.

@cmcgee1024 cmcgee1024 merged commit c82a975 into swiftlang:main Jul 30, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants