дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 01:01:17 +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
+13
-1
@@ -10671,6 +10671,7 @@ export type LanguagesSettings_Deserialize = {
|
||||
arduino?: ArduinoSettings,
|
||||
zig?: ZigSettings,
|
||||
flutter?: FlutterSettings,
|
||||
swift?: SwiftSettings,
|
||||
};
|
||||
|
||||
export type LanguagesSettings_Serialize = {
|
||||
@@ -10695,6 +10696,7 @@ export type LanguagesSettings_Serialize = {
|
||||
arduino: ArduinoSettings,
|
||||
zig: ZigSettings,
|
||||
flutter: FlutterSettings,
|
||||
swift: SwiftSettings,
|
||||
};
|
||||
|
||||
export type LargeCommitFile = {
|
||||
@@ -14510,7 +14512,9 @@ export type SdkKind = "python" | "node" |
|
||||
/** .NET SDKs of the `dotnet` on the search path; `version` is what `global.json` pins. */
|
||||
"dotnet" |
|
||||
/** Flutter SDK roots. */
|
||||
"flutter";
|
||||
"flutter" |
|
||||
/** `Xcode.app` bundles. */
|
||||
"xcode";
|
||||
|
||||
/**
|
||||
* IDEA's search context: matches anywhere, only in, or outside comments and
|
||||
@@ -15461,6 +15465,14 @@ export type StubLink = {
|
||||
|
||||
export type SubmoduleRollbackSource = "head" | "index";
|
||||
|
||||
export type SwiftSettings = {
|
||||
/**
|
||||
* The Xcode (`Xcode.app` or its `Contents/Developer`) whose tools the project's sourcekit-lsp,
|
||||
* `xcodebuild`, `xcrun` and terminals use, as `DEVELOPER_DIR`. Empty = the `xcode-select` one.
|
||||
*/
|
||||
xcode?: string,
|
||||
};
|
||||
|
||||
export type SymbolFilter = "all" |
|
||||
/** Go to Class (⌘O): classes, interfaces, structs, enums, traits, type aliases. */
|
||||
"types";
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -288,6 +288,8 @@ describe("catalogs", () => {
|
||||
"fillfactor=70, autovacuum_enabled=false",
|
||||
// The placeholder of an Xcode run configuration's project or workspace field.
|
||||
"App.xcodeproj",
|
||||
// The Swift settings field naming the Xcode a project uses.
|
||||
"Xcode",
|
||||
// GitHub's product name, the title of its tool window.
|
||||
"GitHub Actions",
|
||||
"Flutter DevTools",
|
||||
|
||||
@@ -194,6 +194,8 @@ export interface LanguagesValid {
|
||||
zig: { zig: string };
|
||||
/** Flutter SDK root; empty = `flutter` / `dart` on PATH. */
|
||||
flutter: { sdk: string };
|
||||
/** `Xcode.app` (or its `Contents/Developer`) the project's Apple tools use; empty = `xcode-select`'s. */
|
||||
swift: { xcode: string };
|
||||
node: {
|
||||
runTarget: string;
|
||||
interpreter: string;
|
||||
@@ -339,6 +341,7 @@ export const DEFAULT_LANGUAGES: LanguagesValid = {
|
||||
ruby: { interpreter: "" },
|
||||
zig: { zig: "" },
|
||||
flutter: { sdk: "" },
|
||||
swift: { xcode: "" },
|
||||
node: { runTarget: "", interpreter: "", packageManager: "", runtime: "" },
|
||||
php: { runTarget: "", interpreter: "", languageLevel: "", includePaths: [], stubs: [], phpstanConfig: "" },
|
||||
rust: { toolchain: "", stdlib: "", checkOnSave: true, checkCommand: "check", rustfmtArgs: "" },
|
||||
@@ -472,6 +475,7 @@ export function validateLanguages(raw: unknown): LanguagesValid {
|
||||
const ruby = obj(l.ruby);
|
||||
const zig = obj(l.zig);
|
||||
const flutter = obj(l.flutter);
|
||||
const swift = obj(l.swift);
|
||||
const node = obj(l.node);
|
||||
const php = obj(l.php);
|
||||
const rust = obj(l.rust);
|
||||
@@ -506,6 +510,7 @@ export function validateLanguages(raw: unknown): LanguagesValid {
|
||||
ruby: { interpreter: text(ruby.interpreter, d.ruby.interpreter) },
|
||||
zig: { zig: text(zig.zig, d.zig.zig) },
|
||||
flutter: { sdk: text(flutter.sdk, d.flutter.sdk) },
|
||||
swift: { xcode: text(swift.xcode, d.swift.xcode) },
|
||||
node: {
|
||||
runTarget: text(node.runTarget, ""),
|
||||
interpreter: text(node.interpreter, d.node.interpreter),
|
||||
|
||||
@@ -6535,6 +6535,9 @@
|
||||
"Select Zig Directory": "Выбрать каталог Zig",
|
||||
"Zig toolchain": "Инструментарий Zig",
|
||||
"Zig whose standard library and build.zig.zon packages appear under External Libraries. ZLS must match this Zig version. PATH, Homebrew, zvm and mise / asdf installs are detected.": "Zig, стандартная библиотека и пакеты build.zig.zon которого отображаются в разделе «Внешние библиотеки». Версия ZLS должна соответствовать этой версии Zig. Обнаруживаются установки из PATH, Homebrew, zvm и mise / asdf.",
|
||||
"Xcode": "Xcode",
|
||||
"Select Xcode": "Выбрать Xcode",
|
||||
"Xcode whose tools this project uses: sourcekit-lsp, xcodebuild, simctl, lldb-dap and terminals get it as DEVELOPER_DIR. Changing it restarts sourcekit-lsp.": "Xcode, инструменты которого использует проект: sourcekit-lsp, xcodebuild, simctl, lldb-dap и терминалы получают его как DEVELOPER_DIR. При изменении sourcekit-lsp перезапускается.",
|
||||
"Monospaced": "Моноширинный",
|
||||
"Proportional": "Пропорциональный",
|
||||
"Loading system fonts…": "Загрузка системных шрифтов…",
|
||||
|
||||
@@ -6054,6 +6054,9 @@
|
||||
"Select Zig Directory": "選擇 Zig 目錄",
|
||||
"Zig toolchain": "Zig 工具鏈",
|
||||
"Zig whose standard library and build.zig.zon packages appear under External Libraries. ZLS must match this Zig version. PATH, Homebrew, zvm and mise / asdf installs are detected.": "用於在「外部庫」下列出 Zig 標準庫和 build.zig.zon 依賴的 Zig。ZLS 版本必須與該 Zig 版本符合。可檢測 PATH、Homebrew、zvm 以及 mise / asdf 的安裝。",
|
||||
"Xcode": "Xcode",
|
||||
"Select Xcode": "選擇 Xcode",
|
||||
"Xcode whose tools this project uses: sourcekit-lsp, xcodebuild, simctl, lldb-dap and terminals get it as DEVELOPER_DIR. Changing it restarts sourcekit-lsp.": "此專案使用其工具的 Xcode:sourcekit-lsp、xcodebuild、simctl、lldb-dap 和終端機會以 DEVELOPER_DIR 取得它。修改後會重新啟動 sourcekit-lsp。",
|
||||
"Monospaced": "等寬",
|
||||
"Proportional": "非等寬",
|
||||
"Loading system fonts…": "正在載入系統字型…",
|
||||
|
||||
@@ -6898,6 +6898,9 @@
|
||||
"Select Zig Directory": "选择 Zig 目录",
|
||||
"Zig toolchain": "Zig 工具链",
|
||||
"Zig whose standard library and build.zig.zon packages appear under External Libraries. ZLS must match this Zig version. PATH, Homebrew, zvm and mise / asdf installs are detected.": "用于在“外部库”下列出 Zig 标准库和 build.zig.zon 依赖的 Zig。ZLS 版本必须与该 Zig 版本匹配。可检测 PATH、Homebrew、zvm 以及 mise / asdf 的安装。",
|
||||
"Xcode": "Xcode",
|
||||
"Select Xcode": "选择 Xcode",
|
||||
"Xcode whose tools this project uses: sourcekit-lsp, xcodebuild, simctl, lldb-dap and terminals get it as DEVELOPER_DIR. Changing it restarts sourcekit-lsp.": "此项目使用其工具的 Xcode:sourcekit-lsp、xcodebuild、simctl、lldb-dap 和终端会以 DEVELOPER_DIR 得到它。修改后会重启 sourcekit-lsp。",
|
||||
"Monospaced": "等宽",
|
||||
"Proportional": "非等宽",
|
||||
"Loading system fonts…": "正在加载系统字体…",
|
||||
|
||||
Reference in new issue
Заблокувати користувача