Skip to content

Commit a769ec2

Browse files
committed
Revert switchPlatform changes
1 parent 7a970e2 commit a769ec2

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
},
166166
{
167167
"command": "swift.switchPlatform",
168-
"title": "Select Swift SDK...",
168+
"title": "Select Target Platform...",
169169
"category": "Swift"
170170
},
171171
{

src/commands/switchPlatform.ts

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
import * as vscode from "vscode";
16-
import { DarwinCompatibleTarget, getDarwinTargetTriple } from "../toolchain/toolchain";
16+
import { DarwinCompatibleTarget, SwiftToolchain } from "../toolchain/toolchain";
1717
import configuration from "../configuration";
1818

1919
/**
@@ -22,27 +22,35 @@ import configuration from "../configuration";
2222
export async function switchPlatform() {
2323
const picked = await vscode.window.showQuickPick(
2424
[
25-
{
26-
value: undefined,
27-
label: "macOS",
28-
description: "default",
29-
},
30-
...[
31-
{ value: DarwinCompatibleTarget.iOS, label: "iOS" },
32-
{ value: DarwinCompatibleTarget.tvOS, label: "tvOS" },
33-
{ value: DarwinCompatibleTarget.watchOS, label: "watchOS" },
34-
{ value: DarwinCompatibleTarget.visionOS, label: "visionOS" },
35-
].map(item => ({
36-
value: getDarwinTargetTriple(item.value),
37-
description: getDarwinTargetTriple(item.value),
38-
label: item.label,
39-
})),
25+
{ value: undefined, label: "macOS" },
26+
{ value: DarwinCompatibleTarget.iOS, label: "iOS" },
27+
{ value: DarwinCompatibleTarget.tvOS, label: "tvOS" },
28+
{ value: DarwinCompatibleTarget.watchOS, label: "watchOS" },
29+
{ value: DarwinCompatibleTarget.visionOS, label: "visionOS" },
4030
],
4131
{
42-
placeHolder: "Select a Swift SDK platform",
32+
placeHolder: "Select a new target",
4333
}
4434
);
4535
if (picked) {
46-
configuration.swiftSDK = picked.value;
36+
try {
37+
const sdkForTarget = picked.value
38+
? await SwiftToolchain.getSDKForTarget(picked.value)
39+
: "";
40+
if (sdkForTarget !== undefined) {
41+
if (sdkForTarget !== "") {
42+
configuration.sdk = sdkForTarget;
43+
vscode.window.showWarningMessage(
44+
`Selecting the ${picked.label} SDK will provide code editing support, but compiling with this SDK will have undefined results.`
45+
);
46+
} else {
47+
configuration.sdk = undefined;
48+
}
49+
} else {
50+
vscode.window.showErrorMessage("Unable to obtain requested SDK path");
51+
}
52+
} catch {
53+
vscode.window.showErrorMessage("Unable to obtain requested SDK path");
54+
}
4755
}
4856
}

0 commit comments

Comments
 (0)