Validate SDK before overwriting

This commit is contained in:
Kabir Oberai
2026-01-04 21:41:29 -05:00
Unverified
parent 22655f3e70
commit cfd90df191
2 changed files with 8 additions and 4 deletions
+4 -1
View File
@@ -18,7 +18,10 @@ struct SDKBuilder {
init(path: String) throws {
var isDir: ObjCBool = false
guard FileManager.default.fileExists(atPath: path, isDirectory: &isDir) else {
throw Console.Error("Could not read file or directory at path '\(path)'")
throw Console.Error("""
Could not read file or directory at path '\(path)'.
See 'xtool help sdk' for usage.
""")
}
let url = URL(fileURLWithPath: path)
+4 -3
View File
@@ -243,14 +243,15 @@ struct InstallSDKOperation {
#if os(macOS)
print("Skipping SDK install; the iOS SDK ships with Xcode on macOS")
#else
// validate input before removing existing SDK
let input = try SDKBuilder.Input(path: path)
let arch = try ArchSelection.auto.sdkBuilderArch
if let sdk = try await DarwinSDK.current() {
print("Removing existing SDK...")
try sdk.remove()
}
let input = try SDKBuilder.Input(path: path)
let arch = try ArchSelection.auto.sdkBuilderArch
let tempDir = try TemporaryDirectory(name: "DarwinSDKBuild")
let builder = SDKBuilder(input: input, outputPath: tempDir.url.path, arch: arch)
let sdkPath = try await builder.buildSDK()