|
14 | 14 |
|
15 | 15 | import * as fs from "fs/promises";
|
16 | 16 | import * as path from "path";
|
| 17 | +import { normalize } from "path"; |
17 | 18 | import * as plist from "plist";
|
18 | 19 | import * as vscode from "vscode";
|
19 | 20 | import configuration from "../configuration";
|
@@ -103,6 +104,30 @@ export class SwiftToolchain {
|
103 | 104 | return stdout.trimEnd();
|
104 | 105 | }
|
105 | 106 |
|
| 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 | + |
106 | 131 | /**
|
107 | 132 | * Get list of Xcode versions intalled on mac
|
108 | 133 | * @returns Folders for each Xcode install
|
@@ -233,30 +258,6 @@ export class SwiftToolchain {
|
233 | 258 | return undefined;
|
234 | 259 | }
|
235 | 260 |
|
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 |
| - |
260 | 261 | /**
|
261 | 262 | * @returns path to custom SDK
|
262 | 263 | */
|
|
0 commit comments