дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 17:21:13 +02:00
feat(swift): choose the Xcode a project uses and pass it to its tools as DEVELOPER_DIR (#6964)
Settings > Languages > Swift gets an Xcode field (empty = the xcode-select one). For a trusted project the chosen Xcode.app or Contents/Developer becomes DEVELOPER_DIR in the project environment, so sourcekit-lsp, xcodebuild, xcrun, simulators, debug adapters and terminals use it; it overrides a DEVELOPER_DIR from .envrc and is not applied to untrusted projects or LightEdit. Closes #6963 Co-authored-by: wildcatDownstairs <[email protected]>
Цей коміт міститься в:
1 джерело
485d7bf99d
коміт
0cfabdbbbd
28 files changed
+403
-32
No files matched your search
@@ -404,6 +404,7 @@ describe("language pages", () => {
|
||||
"dprint",
|
||||
"Ruby",
|
||||
"Rust",
|
||||
"Swift",
|
||||
"TypeScript",
|
||||
"Zig",
|
||||
]);
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { useProject } from "@/platform/project";
|
||||
import type { Sdk } from "@/platform/ipc";
|
||||
|
||||
const ok = <T,>(data: T) => Promise.resolve({ status: "ok" as const, data });
|
||||
const xcode = (path: string, name: string): Sdk => ({
|
||||
path,
|
||||
name,
|
||||
version: null,
|
||||
source: "system",
|
||||
home: `${path}/Contents/Developer`,
|
||||
extra: null,
|
||||
});
|
||||
vi.mock("@/platform/ipc", async (original) => {
|
||||
const actual = await original<typeof import("@/platform/ipc")>();
|
||||
return {
|
||||
...actual,
|
||||
isTauri: () => true,
|
||||
commands: {
|
||||
...actual.commands,
|
||||
sdkDetect: (kind: string) =>
|
||||
ok(
|
||||
kind === "xcode"
|
||||
? [xcode("/Applications/Xcode.app", "Xcode 26.1"), xcode("/Applications/Xcode-beta.app", "Xcode-beta 26.2")]
|
||||
: [],
|
||||
),
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
import { PageContext } from "../components/context";
|
||||
import { SwiftPage } from "../languages/LanguagePages";
|
||||
import { DEFAULT_SETTINGS } from "../model/schema";
|
||||
import { openSettings } from "../model/staging";
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe("Swift settings page", () => {
|
||||
it("lists the installed Xcodes after the xcode-select default", async () => {
|
||||
const settings = structuredClone(DEFAULT_SETTINGS);
|
||||
settings.languages.swift.xcode = "/Applications/Xcode-beta.app";
|
||||
useProject.setState({ settings, project: null });
|
||||
openSettings("languages.swift");
|
||||
render(
|
||||
<PageContext.Provider value={{ pageId: "languages.swift", scope: "project" }}>
|
||||
<SwiftPage />
|
||||
</PageContext.Provider>,
|
||||
);
|
||||
const combo = screen.getByRole("button", { name: "Xcode" });
|
||||
await waitFor(() => expect(combo).toHaveTextContent("Xcode-beta 26.2"));
|
||||
fireEvent.click(combo);
|
||||
const options = await screen.findAllByRole("option");
|
||||
expect(options.map((o) => o.textContent)).toEqual([
|
||||
expect.stringContaining("xcode-select"),
|
||||
expect.stringContaining("Xcode 26.1"),
|
||||
expect.stringContaining("Xcode-beta 26.2"),
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -908,3 +908,26 @@ export function ZigPage() {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Swift
|
||||
|
||||
export function SwiftPage() {
|
||||
return (
|
||||
<div className={styles.page}>
|
||||
<Section>
|
||||
<SdkRow
|
||||
k="languages.swift.xcode"
|
||||
label="Xcode"
|
||||
kind="xcode"
|
||||
emptyLabel="Default"
|
||||
emptyDetail="xcode-select"
|
||||
directory
|
||||
browseTitle="Select Xcode"
|
||||
aria-label="Xcode"
|
||||
hint="Xcode whose tools this project uses: sourcekit-lsp, xcodebuild, simctl, lldb-dap and terminals get it as DEVELOPER_DIR. Changing it restarts sourcekit-lsp."
|
||||
/>
|
||||
</Section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* PyCharm's top-level "Python" group (Interpreter) and
|
||||
* Languages & Frameworks › Flutter / Go / Java / Markdown / Node.js / PHP / Rust / TypeScript / Zig. Pages live in
|
||||
* Languages & Frameworks › Flutter / Go / Java / Markdown / Node.js / PHP / Rust / Swift / TypeScript / Zig. Pages live in
|
||||
* `../languages/`; settings are `languages.*` / `projectStructure.*`.
|
||||
*/
|
||||
import { GO_BUILD_TAG_SECTIONS, GoBuildTagsPage } from "../languages/GoBuildTags";
|
||||
@@ -50,6 +50,7 @@ const JsonSchemasEditor = lazyPage("languages.jsonSchemas", () =>
|
||||
import("./JsonSchemasBody").then((m) => m.JsonSchemasEditor),
|
||||
);
|
||||
const ZigPage = lazyPage("languages.zig", () => import("../languages/LanguagePages").then((m) => m.ZigPage));
|
||||
const SwiftPage = lazyPage("languages.swift", () => import("../languages/LanguagePages").then((m) => m.SwiftPage));
|
||||
|
||||
export const LANGUAGES_GROUP = "Languages & Frameworks";
|
||||
|
||||
@@ -401,6 +402,16 @@ export const LANGUAGE_PAGES: PageSpec[] = [
|
||||
keywords: ["typescript version", "tsdk", "tsserver", "node_modules", "vtsls", "tsserver log"],
|
||||
component: TypeScriptPage,
|
||||
},
|
||||
{
|
||||
id: "languages.swift",
|
||||
projectScope: true,
|
||||
defaultScope: "project",
|
||||
title: "Swift",
|
||||
group: LANGUAGES_GROUP,
|
||||
order: 404.5,
|
||||
keywords: ["xcode", "xcode version", "developer_dir", "xcode-select", "sourcekit-lsp", "xcodebuild", "ios"],
|
||||
component: SwiftPage,
|
||||
},
|
||||
{
|
||||
id: "languages.zig",
|
||||
projectScope: true,
|
||||
|
||||
Reference in new issue
Заблокувати користувача