Skip to content

Create a special Xcode selector for macOS #317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

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.

@@ -49,8 +49,14 @@ public struct Config: Codable, Equatable, Sendable {
}

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?

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