@@ -63,7 +63,7 @@ export async function selectToolchainFolder() {
63
63
if ( ! selected || selected . length !== 1 ) {
64
64
return ;
65
65
}
66
- await setToolchainPath ( selected [ 0 ] . fsPath , "public" ) ;
66
+ await setToolchainPath ( selected [ 0 ] . fsPath ) ;
67
67
}
68
68
69
69
/**
@@ -275,15 +275,25 @@ export async function showToolchainSelectionQuickPick(activeToolchain: SwiftTool
275
275
}
276
276
if ( selected ?. type === "toolchain" ) {
277
277
// Select an Xcode to build with
278
- let developerDir : string | undefined ;
279
- if ( selected . category === "xcode" ) {
280
- developerDir = selected . xcodePath ;
281
- } else if ( xcodePaths . length === 1 ) {
282
- developerDir = xcodePaths [ 0 ] ;
283
- } else if ( process . platform === "darwin" && xcodePaths . length > 1 ) {
284
- developerDir = await showDeveloperDirQuickPick ( xcodePaths ) ;
285
- if ( ! developerDir ) {
286
- return ;
278
+ let developerDir : string | undefined = undefined ;
279
+ if ( process . platform === "darwin" ) {
280
+ let selectedXcodePath : string | undefined = undefined ;
281
+ if ( selected . category === "xcode" ) {
282
+ selectedXcodePath = selected . xcodePath ;
283
+ } else if ( xcodePaths . length === 1 ) {
284
+ selectedXcodePath = xcodePaths [ 0 ] ;
285
+ } else if ( xcodePaths . length > 1 ) {
286
+ selectedXcodePath = await showDeveloperDirQuickPick ( xcodePaths ) ;
287
+ if ( ! selectedXcodePath ) {
288
+ return ;
289
+ }
290
+ }
291
+ // Find the actual DEVELOPER_DIR based on the selected Xcode app
292
+ if ( selectedXcodePath ) {
293
+ developerDir = await SwiftToolchain . getXcodeDeveloperDir ( {
294
+ ...process . env ,
295
+ DEVELOPER_DIR : selectedXcodePath ,
296
+ } ) ;
287
297
}
288
298
}
289
299
// Update the toolchain path
@@ -376,7 +386,7 @@ async function removeToolchainPath() {
376
386
*/
377
387
async function setToolchainPath (
378
388
swiftFolderPath : string | undefined ,
379
- developerDir : string | undefined
389
+ developerDir ? : string
380
390
) : Promise < boolean > {
381
391
let target : vscode . ConfigurationTarget | undefined ;
382
392
const items : ( vscode . QuickPickItem & {
@@ -410,17 +420,15 @@ async function setToolchainPath(
410
420
}
411
421
const swiftConfiguration = vscode . workspace . getConfiguration ( "swift" ) ;
412
422
await swiftConfiguration . update ( "path" , swiftFolderPath , target ) ;
413
- if ( developerDir ) {
414
- const swiftEnv = configuration . swiftEnvironmentVariables ;
415
- await swiftConfiguration . update (
416
- "swiftEnvironmentVariables" ,
417
- {
418
- ...swiftEnv ,
419
- DEVELOPER_DIR : developerDir ,
420
- } ,
421
- target
422
- ) ;
423
- }
423
+ const swiftEnv = configuration . swiftEnvironmentVariables ;
424
+ await swiftConfiguration . update (
425
+ "swiftEnvironmentVariables" ,
426
+ {
427
+ ...swiftEnv ,
428
+ DEVELOPER_DIR : developerDir ,
429
+ } ,
430
+ target
431
+ ) ;
424
432
await checkAndRemoveWorkspaceSetting ( target ) ;
425
433
return true ;
426
434
}
0 commit comments