From 66c91cb4c3e249a7cea88f58e7f55bc7eb118f79 Mon Sep 17 00:00:00 2001 From: justiceadams Date: Mon, 8 Dec 2025 12:42:29 -0800 Subject: [PATCH 1/3] Ensure the macOS SDK exists at install time --- Sources/MacOSPlatform/MacOS.swift | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/Sources/MacOSPlatform/MacOS.swift b/Sources/MacOSPlatform/MacOS.swift index b68f1ca1..77dc7594 100644 --- a/Sources/MacOSPlatform/MacOS.swift +++ b/Sources/MacOSPlatform/MacOS.swift @@ -48,11 +48,33 @@ public struct MacOS: Platform { } public func verifySystemPrerequisitesForInstall( - _: SwiftlyCoreContext, platformName _: String, version _: ToolchainVersion, + _ ctx: SwiftlyCoreContext, platformName _: String, version _: ToolchainVersion, requireSignatureValidation _: Bool ) async throws -> String? { - // All system prerequisites should be there for macOS - nil + // Ensure that there is in fact a macOS SDK installed so the toolchain is usable. + let result = try await run( + .path(SystemPackage.FilePath("/usr/bin/xcrun")), + arguments: ["--show-sdk-path", "--sdk", "macosx"], + output: .string(limit: 1024 * 10) + ) + + // Simply print warnings to the user stdout rather than returning a shell script, as there is not a simple + // shell script for installing developer tools on macOS. + if !result.terminationStatus.isSuccess { + await ctx.print(""" + \nWARNING: Could not find a macOS SDK on the system. A macOS SDK is required for the toolchain to work correctly. Please install one via Xcode (https://developer.apple.com/xcode) or run the following command on your machine to install the command line developer tools: `xcode-select --install`. + + If developer tools are located at a non-default location on disk, use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools.\n + """) + } + + let sdkPath = result.standardOutput?.replacingOccurrences(of: "\n", with: "") + + if sdkPath == nil { + await ctx.print("WARNING: Could not read output of '/usr/bin/xcrun --show-sdk-path --sdk macosx'. Ensure your macOS SDK is installed properly for the swift toolchain to work.") + } + + return nil } public func install( From 8d1963d636559a7c235bb34b20a615acd3f9d07b Mon Sep 17 00:00:00 2001 From: justiceadams Date: Fri, 12 Dec 2025 10:50:15 -0800 Subject: [PATCH 2/3] update warning messaging --- Sources/MacOSPlatform/MacOS.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sources/MacOSPlatform/MacOS.swift b/Sources/MacOSPlatform/MacOS.swift index 77dc7594..164e8298 100644 --- a/Sources/MacOSPlatform/MacOS.swift +++ b/Sources/MacOSPlatform/MacOS.swift @@ -62,9 +62,10 @@ public struct MacOS: Platform { // shell script for installing developer tools on macOS. if !result.terminationStatus.isSuccess { await ctx.print(""" - \nWARNING: Could not find a macOS SDK on the system. A macOS SDK is required for the toolchain to work correctly. Please install one via Xcode (https://developer.apple.com/xcode) or run the following command on your machine to install the command line developer tools: `xcode-select --install`. + \nWARNING: Could not find a macOS SDK on the system. A macOS SDK is required for the toolchain to work correctly. Please install one via Xcode (https://developer.apple.com/xcode) or run the following command on your machine to install the Command Line Tools for Xcode:\n`xcode-select --install`. - If developer tools are located at a non-default location on disk, use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools.\n + More information on installing the Command Line Tools can be found here: https://developer.apple.com/documentation/xcode/installing-the-command-line-tools/#Install-the-Command-Line-Tools-package-in-Terminal. If developer tools are located at a non-default location on disk, use the following command to specify the Xcode that you wish to use for Command Line Tools for Xcode: + `sudo xcode-select --switch path/to/Xcode.app`\n """) } From 1c45a1e9660cd2558fc4ef9dda3039eb4a70c69f Mon Sep 17 00:00:00 2001 From: justiceadams Date: Fri, 12 Dec 2025 11:00:36 -0800 Subject: [PATCH 3/3] remove backticks --- Sources/MacOSPlatform/MacOS.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sources/MacOSPlatform/MacOS.swift b/Sources/MacOSPlatform/MacOS.swift index 164e8298..cd97c1a2 100644 --- a/Sources/MacOSPlatform/MacOS.swift +++ b/Sources/MacOSPlatform/MacOS.swift @@ -62,10 +62,11 @@ public struct MacOS: Platform { // shell script for installing developer tools on macOS. if !result.terminationStatus.isSuccess { await ctx.print(""" - \nWARNING: Could not find a macOS SDK on the system. A macOS SDK is required for the toolchain to work correctly. Please install one via Xcode (https://developer.apple.com/xcode) or run the following command on your machine to install the Command Line Tools for Xcode:\n`xcode-select --install`. + \nWARNING: Could not find a macOS SDK on the system. A macOS SDK is required for the toolchain to work correctly. Please install one via Xcode (https://developer.apple.com/xcode) or run the following command on your machine to install the Command Line Tools for Xcode: + xcode-select --install More information on installing the Command Line Tools can be found here: https://developer.apple.com/documentation/xcode/installing-the-command-line-tools/#Install-the-Command-Line-Tools-package-in-Terminal. If developer tools are located at a non-default location on disk, use the following command to specify the Xcode that you wish to use for Command Line Tools for Xcode: - `sudo xcode-select --switch path/to/Xcode.app`\n + sudo xcode-select --switch path/to/Xcode.app\n """) }