Skip to content

Use xcode-select to determine the actual DEVELOPER_DIR value #1433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 30 additions & 22 deletions src/ui/ToolchainSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export async function selectToolchainFolder() {
if (!selected || selected.length !== 1) {
return;
}
await setToolchainPath(selected[0].fsPath, "public");
await setToolchainPath(selected[0].fsPath);
}

/**
Expand Down Expand Up @@ -275,15 +275,25 @@ export async function showToolchainSelectionQuickPick(activeToolchain: SwiftTool
}
if (selected?.type === "toolchain") {
// Select an Xcode to build with
let developerDir: string | undefined;
if (selected.category === "xcode") {
developerDir = selected.xcodePath;
} else if (xcodePaths.length === 1) {
developerDir = xcodePaths[0];
} else if (process.platform === "darwin" && xcodePaths.length > 1) {
developerDir = await showDeveloperDirQuickPick(xcodePaths);
if (!developerDir) {
return;
let developerDir: string | undefined = undefined;
if (process.platform === "darwin") {
let selectedXcodePath: string | undefined = undefined;
if (selected.category === "xcode") {
selectedXcodePath = selected.xcodePath;
} else if (xcodePaths.length === 1) {
selectedXcodePath = xcodePaths[0];
} else if (xcodePaths.length > 1) {
selectedXcodePath = await showDeveloperDirQuickPick(xcodePaths);
if (!selectedXcodePath) {
return;
}
}
// Find the actual DEVELOPER_DIR based on the selected Xcode app
if (selectedXcodePath) {
developerDir = await SwiftToolchain.getXcodeDeveloperDir({
...process.env,
DEVELOPER_DIR: selectedXcodePath,
});
}
}
// Update the toolchain path
Expand Down Expand Up @@ -376,7 +386,7 @@ async function removeToolchainPath() {
*/
async function setToolchainPath(
swiftFolderPath: string | undefined,
developerDir: string | undefined
developerDir?: string
): Promise<boolean> {
let target: vscode.ConfigurationTarget | undefined;
const items: (vscode.QuickPickItem & {
Expand Down Expand Up @@ -410,17 +420,15 @@ async function setToolchainPath(
}
const swiftConfiguration = vscode.workspace.getConfiguration("swift");
await swiftConfiguration.update("path", swiftFolderPath, target);
if (developerDir) {
const swiftEnv = configuration.swiftEnvironmentVariables;
await swiftConfiguration.update(
"swiftEnvironmentVariables",
{
...swiftEnv,
DEVELOPER_DIR: developerDir,
},
target
);
}
const swiftEnv = configuration.swiftEnvironmentVariables;
await swiftConfiguration.update(
"swiftEnvironmentVariables",
{
...swiftEnv,
DEVELOPER_DIR: developerDir,
},
target
);
await checkAndRemoveWorkspaceSetting(target);
return true;
}
Expand Down
Loading