Skip to content

Commit 100dc8d

Browse files
committed
Remove DarwinQuickPickTarget. We don't need it
1 parent 993cfe4 commit 100dc8d

File tree

2 files changed

+34
-40
lines changed

2 files changed

+34
-40
lines changed

src/commands.ts

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -431,31 +431,24 @@ function openInExternalEditor(packageNode: PackageNode) {
431431
}
432432
}
433433

434-
interface DarwinQuickPickTarget extends vscode.QuickPickItem {
435-
value: DarwinCompatibleTarget;
436-
label: string;
437-
}
438-
439434
/**
440435
* Switches the target SDK to the platform selected in a QuickPick UI.
441436
*/
442437
async function switchPlatform() {
443-
const onSelect = async (picked: DarwinQuickPickTarget) => {
444-
const sdkForTarget = await SwiftToolchain.getSdkForTarget(picked.value);
445-
if (sdkForTarget) {
446-
configuration.sdk = sdkForTarget;
447-
} else {
448-
vscode.window.showErrorMessage("Unable to obtain requested SDK path");
449-
}
450-
};
451-
452-
await withQuickPick<DarwinQuickPickTarget>(
438+
await withQuickPick(
453439
"Select a new target",
454440
[
455441
{ value: DarwinCompatibleTarget.macOS, label: "macOS" },
456442
{ value: DarwinCompatibleTarget.iOS, label: "iOS" },
457443
],
458-
onSelect
444+
async picked => {
445+
const sdkForTarget = await SwiftToolchain.getSdkForTarget(picked.value);
446+
if (sdkForTarget) {
447+
configuration.sdk = sdkForTarget;
448+
} else {
449+
vscode.window.showErrorMessage("Unable to obtain requested SDK path");
450+
}
451+
}
459452
);
460453
}
461454

src/toolchain/toolchain.ts

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import * as fs from "fs/promises";
1616
import * as path from "path";
17+
import { normalize } from "path";
1718
import * as plist from "plist";
1819
import * as vscode from "vscode";
1920
import configuration from "../configuration";
@@ -103,6 +104,30 @@ export class SwiftToolchain {
103104
return stdout.trimEnd();
104105
}
105106

107+
/**
108+
* @param target Target to obtain the SDK path for
109+
* @returns path to the SDK for the target
110+
*/
111+
public static async getSdkForTarget(
112+
target: DarwinCompatibleTarget
113+
): Promise<string | undefined> {
114+
let sdkType: string;
115+
switch (target) {
116+
case DarwinCompatibleTarget.macOS:
117+
// macOS is the default target, so lets not update the SDK
118+
return undefined;
119+
case DarwinCompatibleTarget.iOS:
120+
sdkType = "iphoneos";
121+
break;
122+
}
123+
124+
// Include custom variables so that non-standard XCode installs can be better supported.
125+
const { stdout } = await execFile("xcrun", ["--sdk", sdkType, "--show-sdk-path"], {
126+
env: { ...process.env, ...configuration.swiftEnvironmentVariables },
127+
});
128+
return path.join(stdout.trimEnd());
129+
}
130+
106131
/**
107132
* Get list of Xcode versions intalled on mac
108133
* @returns Folders for each Xcode install
@@ -233,30 +258,6 @@ export class SwiftToolchain {
233258
return undefined;
234259
}
235260

236-
/**
237-
* @param target Target to obtain the SDK path for
238-
* @returns path to the SDK for the target
239-
*/
240-
public static async getSdkForTarget(
241-
target: DarwinCompatibleTarget
242-
): Promise<string | undefined> {
243-
let sdkType: string;
244-
switch (target) {
245-
case DarwinCompatibleTarget.macOS:
246-
sdkType = "macosx";
247-
break;
248-
case DarwinCompatibleTarget.iOS:
249-
sdkType = "iphoneos";
250-
break;
251-
}
252-
253-
// Include custom variables so that non-standard XCode installs can be better supported.
254-
const { stdout } = await execFile("xcrun", ["--sdk", sdkType, "--show-sdk-path"], {
255-
env: { ...process.env, ...configuration.swiftEnvironmentVariables },
256-
});
257-
return path.join(stdout.trimEnd());
258-
}
259-
260261
/**
261262
* @returns path to custom SDK
262263
*/

0 commit comments

Comments
 (0)